What is the best way to use ES6 with rails asset pipeline?. I am trying to write some es6 syntax in my angular-rails application, which uses the rails asset pipeline. The code actually works in local but throws a syntax error when trying to deploy(digital ocean).
This is error I am getting while I am deploying. And the code I am trying to run is
class Hello {
constructor() {
alert('Hello!');
}
}
new Hello();
Current uglifier version doesn't support ES6, It is on experimental mode hence you will need to manually enable ES6 compiling.
You will need latest uglifier gem version.
ES6 support can be enabled with :harmony => true
option while setting js_compressor in config/environments/production.rb
:
config.assets.js_compressor = Uglifier.new(
# ES6 support
:harmony => true
)
Check here official docs
Hope it helps
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