diff options
author | Richard Hulse <richard.hulse@radionz.co.nz> | 2011-07-03 17:20:04 +1200 |
---|---|---|
committer | Richard Hulse <richard.hulse@radionz.co.nz> | 2011-07-03 17:20:04 +1200 |
commit | a715c37218d0ebc46d48104d474a4ef9a3acda9a (patch) | |
tree | 9fe4f0daf2cf6f0e9b857b154bc3d322d068eada /railties | |
parent | c7dec1716ef102226598974cf48a75aed58a6411 (diff) | |
download | rails-a715c37218d0ebc46d48104d474a4ef9a3acda9a.tar.gz rails-a715c37218d0ebc46d48104d474a4ef9a3acda9a.tar.bz2 rails-a715c37218d0ebc46d48104d474a4ef9a3acda9a.zip |
[asset pipeline] expand section on configuration
Diffstat (limited to 'railties')
-rw-r--r-- | railties/guides/source/asset_pipeline.textile | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/railties/guides/source/asset_pipeline.textile b/railties/guides/source/asset_pipeline.textile index 91fe454d94..19e2d736e0 100644 --- a/railties/guides/source/asset_pipeline.textile +++ b/railties/guides/source/asset_pipeline.textile @@ -246,24 +246,29 @@ The following line will enable SCSS in you project. config.assets.css_compressor = :scss </erb> +This option is for compression only and does not relate to the SCSS language extensions that apply when using the +.scss+ file extension on CSS assets. h4. Javascript -TODO: Talk about the options +There are three options available to process javascript - uglifier, closure and yui. + +The default Gemfile includes "uglifier":https://github.com/lautis/uglifier. This gem wraps "UglifierJS":https://github.com/mishoo/UglifyJS (written for NodeJS) in Ruby. It compress your code by removing white spaces and other magical things like changing your if and else statements to ternary operators when possible. + +TODO: Add detail about the other two + +The following line will invoke uglifier for Javascript compression. <erb> config.assets.js_compressor = :uglifier </erb> -Current options are uglifier, closure, yui -The default Gemfile also includes the "uglifier":https://github.com/lautis/uglifier gem. This gem wraps "UglifierJS":https://github.com/mishoo/UglifyJS (written for NodeJS) in Ruby. It compress your code by removing white spaces and other magical things like changing your if and else statements to ternary operators when possible. h4. Using your own compressor -The config setting shown above will also take an Object. +The compressor config settings for CSS and Javascript will also take an Object. -This object must have a 'compress' method that takes a string as the sole argument and it must return a string. +This object must have a +compress+ method that takes a string as the sole argument and it must return a string. <erb> class Transformer @@ -273,20 +278,24 @@ class Transformer end </erb> -And the config: +To enable this pass a +new+ Object to the config option in +application.rb+: <erb> config.assets.css_compressor = Transformer.new </erb> -h4. Changing the 'assets' path +h4. Changing the _assets_ path -The public path that Sprockets uses is +/assets+. +The public path that Sprockets uses by default is +/assets+. -This can be changed thus: +This can be changed to something else: + +<erb> +config.assets.prefix = "/some_other_path" +</erb> -config.assets.prefix = "/some_other_path" +This is a handy option if you have any existing project (pre Rails 3.1) that already uses this path. h3. Adding Assets to Your Gems |