Class: SC::Builder::SplitCSS
- Defined in:
- lib/sproutcore/builders/split.rb
Overview
This builder is used to split packed CSS files, ironically enough, into smaller CSS files. This is due to an IE limitation of ~4096 maximum selectors per file.
This is a bit hacky, but we add additional manifest entries even though, technically, the manifest generation process is finished. We do this because we have NO WAY of knowing how many selectors there will be until CSS is both built and packed.
The static HTML helper makes sure to build! the packed stylesheet entries first so that this rule has been processed. After that, it looks for [:split_entries] on the packed entry.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
build, #initialize, #joinlines, #read, #readlines, #replace_static_url, #sc_static_match, #static_url, #writeline, #writelinebinary, #writelines
Constructor Details
This class inherits a constructor from SC::Builder::Base
Instance Method Details
#build(dst_path) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/sproutcore/builders/split.rb', line 23 def build(dst_path) e = entry.source_entry e.stage! src = File.read(entry[:staging_path]) files = SC::Helpers::SplitCSS.split_css src if files.length > 1 and entry.target.config[:split_css_for_ie] entry[:split_entries] = [] entry[:is_split] = true entry.hide! files.each_index {|index| name = entry[:filename].sub /\.css$/, "" path = dst_path.sub /\.css$/, "" path = "#{path}-#{index}.css" writeline path, files[index] # Is this hacky? Yes. But IE is stupid. So we have to modify the manifest # very late, because we don't know the resource_name = "#{name}-#{index}.css" split_entry = entry.manifest.add_composite resource_name, :staging_path => path, :build_path => path, :source_entries => [entry], :url => [entry.manifest[:url_root], resource_name].join("/"), :timestamp => entry[:timestamp] entry[:split_entries] << split_entry } else e.build! end end |