Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rake assets:precompile
loads the application but does not initializ…
…e it. To the app developer, this means configuration add in config/initializers/* will not be executed. Plugins developers need to special case their initializers that are meant to be run in the assets group by adding :group => :assets. Conflicts: railties/CHANGELOG railties/test/application/assets_test.rb
- Loading branch information
Showing
11 changed files
with
183 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,65 @@ | |||
module Sprockets | |||
class Bootstrap | |||
def initialize(app) | |||
@app = app | |||
end | |||
|
|||
# TODO: Get rid of config.assets.enabled | |||
def run | |||
app, config = @app, @app.config | |||
return unless app.assets | |||
|
|||
config.assets.paths.each { |path| app.assets.append_path(path) } | |||
|
|||
if config.assets.compress | |||
# temporarily hardcode default JS compressor to uglify. Soon, it will work | |||
# the same as SCSS, where a default plugin sets the default. | |||
unless config.assets.js_compressor == false | |||
app.assets.js_compressor = LazyCompressor.new { expand_js_compressor(config.assets.js_compressor || :uglifier) } | |||
end | |||
|
|||
unless config.assets.css_compressor == false | |||
app.assets.css_compressor = LazyCompressor.new { expand_css_compressor(config.assets.css_compressor) } | |||
end | |||
end | |||
|
|||
if config.assets.compile | |||
app.routes.prepend do | |||
mount app.assets => config.assets.prefix | |||
end | |||
end | |||
|
|||
if config.assets.digest | |||
app.assets = app.assets.index | |||
end | |||
end | |||
|
|||
protected | |||
|
|||
def expand_js_compressor(sym) | |||
case sym | |||
when :closure | |||
require 'closure-compiler' | |||
Closure::Compiler.new | |||
when :uglifier | |||
require 'uglifier' | |||
Uglifier.new | |||
when :yui | |||
require 'yui/compressor' | |||
YUI::JavaScriptCompressor.new | |||
else | |||
sym | |||
end | |||
end | |||
|
|||
def expand_css_compressor(sym) | |||
case sym | |||
when :yui | |||
require 'yui/compressor' | |||
YUI::CssCompressor.new | |||
else | |||
sym | |||
end | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.