如何使IE11中的VueJS-Symfony应用程序正常工作?
我正在使用Babel Encore
。
[已经在Stack
中检查了可用的答案,但对我不起作用。另外,尝试将@babel/polyfill
直接导入也不起作用的JS。
这是我的应用程序的webpack.config.js
配置
const {VueLoaderPlugin} = require('vue-loader');
let Encore = require('@symfony/webpack-encore');
Encore
.setOutputPath('public/build/')
.setPublicPath('/build')
.cleanupOutputBeforeBuild()
.enableSourceMaps(!Encore.isProduction())
.addEntry('app', './assets/js/app.js')
// .enableVueLoader()
.addLoader({
test: /\.vue$/,
loader: 'vue-loader'
})
.enableBuildNotifications()
// .configureBabel(() => {}, {
// useBuiltIns: 'entry',
// corejs: 3
// })
.addPlugin(new VueLoaderPlugin())
.enableSassLoader()
.enableVersioning(Encore.isProduction())
;
module.exports = Encore.getWebpackConfig();
注意:IE浏览器现在在控制台SCRIPT1010: Expected identifier
中显示错误并显示空白页。
通过更新配置解决的问题
const {VueLoaderPlugin} = require('vue-loader');
let Encore = require('@symfony/webpack-encore');
Encore
.setOutputPath('public/build/')
.setPublicPath('/build')
.cleanupOutputBeforeBuild()
.enableSourceMaps(!Encore.isProduction())
.addEntry('app', './assets/js/app.js')
.addLoader({
test: /\.vue$/,
loader: 'vue-loader'
})
.enableBuildNotifications()
.addPlugin(new VueLoaderPlugin())
.enableSassLoader()
.enableVersioning(Encore.isProduction())
.configureBabel(function(babelConfig) {
// add additional presets
// babelConfig.presets.push('@babel/preset-flow');
// no plugins are added by default, but you can add some
// babelConfig.plugins.push('styled-jsx/babel');
}, {
// node_modules is not processed through Babel by default
// but you can whitelist specific modules to process
// includeNodeModules: ['foundation-sites'],
// or completely control the exclude rule (note that you
// can't use both "includeNodeModules" and "exclude" at
// the same time)
exclude: /loadash/
});
module.exports = Encore.getWebpackConfig();