После добавления ES6 JavaScript в мой проект Rails:
class SpinnerWindow {
static show() {
//...
}
static autoHideShow(timeout=1500) {
//...
}
static hide() {
//...
}
}
и развертывание на Heroku по-прежнему содержит скомпилированный ES6 (не ES5!)
...</div> </div></div>';class SpinnerWindow{static show(){...
Я добавил все необходимые конфигурации в .babelrc
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": "> 1%",
"uglify": true
},
"useBuiltIns": true
}]
],
"plugins": [
"syntax-dynamic-import",
"transform-object-rest-spread",
"transform-es2015-arrow-functions",
"transform-es2015-block-scoped-functions",
"transform-es2015-block-scoping",
"transform-es2015-classes",
"transform-es2015-computed-properties",
"transform-es2015-destructuring",
"transform-es2015-for-of",
"transform-es2015-function-name",
"transform-es2015-literals",
"transform-es2015-modules-commonjs",
"transform-es2015-object-super",
"transform-es2015-parameters",
"transform-es2015-shorthand-properties",
"transform-es2015-spread",
"transform-es2015-sticky-regex",
"transform-es2015-template-literals",
"transform-es2015-typeof-symbol",
"transform-es2015-unicode-regex",
"transform-regenerator",
"transform-async-to-generator",
["transform-class-properties", { "spec": true }],
// Reference assets directly from app/assets/**
// https://github.com/rails/webpacker/blob/master/docs/assets.md#using-babel-module-resolver
["module-resolver", { "root": ["./app"], "alias": { "assets": "./app/assets" } }]
]
}
Также я добавил в 'production.rb'
:
# Compress JavaScripts and CSS.
config.assets.js_compressor = Uglifier.new(harmony: true)
это упомянуто здесь
Как использовать ES6 (ES2015) в приложении ruby on rails?
Версия:
gem 'rails', '4.2.10'
gem 'webpacker', '~> 3.6'
gem 'babel-transpiler'