我已经实现了 FlipClockJs vue component当我运行时它工作正常
yarn encore dev
但是,一旦我跑起来
yarn encore production
出现以下错误
ERROR Failed to compile with 1 errors12:30:24 PM
error
app.bc30a410.js from UglifyJs Unexpected token: operator (>) [app.bc30a410.js:12470,21]
我尝试通过将其添加到我的 webpack 文件中来解决此问题:
.addLoader({
test: /\.js$/,
loader: "babel-loader",
include: ['node_modules/@mvpleung/flipclock']
})
但这只是给了我相同的结果。我的整个 webpack 文件如下所示:
var Encore = require("@symfony/webpack-encore");
const { VueLoaderPlugin } = require("vue-loader");
const MinifyPlugin = require('babel-minify-webpack-plugin');
Encore.setOutputPath("public/build/")
.setPublicPath("/build")
.addEntry("app", "./resources/assets/js/app.js")
.cleanupOutputBeforeBuild()
.enableSourceMaps(!Encore.isProduction())
.enableVersioning(Encore.isProduction())
.addLoader({
test: /\.vue$/,
loader: "vue-loader"
})
.addLoader({
test: /\.js$/,
loader: 'babel-loader',
include: ['/node_modules/@mvpleung/flipclock']
})
.addLoader({
test: /\.(js|vue)$/,
enforce: "pre",
loader: "eslint-loader",
exclude: /node_modules/,
options: {
fix: true
}
})
.addPlugin(new VueLoaderPlugin())
.addPlugin(new MinifyPlugin())
.addAliases({
vue: "vue/dist/vue.js"
})
.enableSassLoader()
.enablePostCssLoader()
;
module.exports = Encore.getWebpackConfig();
知道这里可能出了什么问题吗?该组件在运行 yarn encore dev 时工作正常。
使用 Vue 2.5.17
最佳答案
尝试在您的配置中添加以下内容
optimization: { minimize: false },
关于javascript - babel-loader 不工作,在 UglifyJS (ES6) 上出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53958729/