I've added the closure-compiler gem to my Gemfile and set
config.assets.js_compressor = :closure
in the config/environments/production.rb file.
I believe this defaults to using the SIMPLE_OPTIMIZATIONS compilation level and I was wondering if there is a config variable I can set somewhere to specify the advanced level instead.
I tried digging through the sprockets code but haven't found a way to pass options to the js_compressor yet.
Sprockets allows to organize an application's JavaScript files into smaller more manageable chunks that can be distributed over a number of directories and files. It provides structure and practices on how to include assets in our projects.
The value of this parameter indicates the degree of compression and optimization to apply to your JavaScript. There are three possible compilation levels: WHITESPACE_ONLY , SIMPLE_OPTIMIZATIONS , and ADVANCED_OPTIMIZATIONS .
Check out this issue: https://github.com/rails/rails/issues/2693
To put in simple terms, the given solution is:
# config.assets.js_compressor = :closure
require 'closure-compiler'
config.assets.js_compressor = Closure::Compiler.new(compilation_level: 'ADVANCED_OPTIMIZATIONS')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With