导轨,链轮,谷歌关闭和高级选择

Web*_*dev 5 ruby-on-rails google-closure-compiler sprockets

我已经将closure-compiler gem添加到我的Gemfile并设置了

config.assets.js_compressor = :closure
Run Code Online (Sandbox Code Playgroud)

在config/environments/production.rb文件中.

我相信这默认使用SIMPLE_OPTIMIZATIONS编译级别,我想知道是否有一个配置变量我可以在某处设置以指定高级级别.

我尝试挖掘sprockets代码,但还没有找到将选项传递给js_compressor的方法.

Alc*_*iar 8

看看这个问题:https: //github.com/rails/rails/issues/2693

简而言之,给定的解决方案是:

# config.assets.js_compressor = :closure
require 'closure-compiler'
config.assets.js_compressor = Closure::Compiler.new(compilation_level: 'ADVANCED_OPTIMIZATIONS')
Run Code Online (Sandbox Code Playgroud)