Решение
.configureBabel(function(babelConfig) {
babelConfig.presets = ['es2015','stage-2']
babelConfig.plugins = ['transform-runtime']
})
Все содержимое файла
var Encore = require('@symfony/webpack-encore');
Encore
// the project directory where compiled assets will be stored
.setOutputPath('public/build/')
// the public path used by the web server to access the previous directory
.setPublicPath('/build')
.cleanupOutputBeforeBuild()
//.createSharedEntry('assets', ['babel-polyfill'])
.enableSourceMaps(!Encore.isProduction())
// uncomment to create hashed filenames (e.g. app.abc123.css)
// .enableVersioning(Encore.isProduction())
// uncomment to define the assets of the project
.addEntry('js/app', './assets/js/app.js')
.addEntry('vue', './assets/js/Vue/main.js')
.addStyleEntry('css/app', './assets/scss/style.scss')
.addStyleEntry('css/vue', './assets/scss/vue.scss')
// uncomment if you use Sass/SCSS files
.enableSassLoader()
.autoProvidejQuery()
.enableVueLoader()
.enableSassLoader(function(sassOptions) {}, {
resolveUrlLoader: false
})
.configureBabel(function(babelConfig) {
babelConfig.presets = ['es2015','stage-2']
babelConfig.plugins = ['transform-runtime']
})
;
module.exports = Encore.getWebpackConfig();
Конечно, вы должны установить пакеты
npm install babel-preset-stage-2
npm install babel-preset-es2015 (or es2017)
npm install babel-plugin-transform-runtime