gpt4 book ai didi

javascript - UglifyJs 中的 build.js 中出现错误 意外 token : punc (()

转载 作者:行者123 更新时间:2023-12-03 01:57:11 25 4
gpt4 key购买 nike

我在本地开发了一个应用程序。客户端和服务器运行在不同的端口上。该应用程序在我的本地系统上运行良好。我现在已将代码推送到服务器上。当我尝试使用 npm run build 运行代码时。

我收到如下错误

enter image description here

我的 urlMixin.js 看起来像这样

let path = require('path');

let webpack = require('webpack');

module.exports = {
entry: './src/main.js',
output: {
path: path.resolve(__dirname, './dist'),
publicPath: '/dist/',
filename: 'build.js'
},
module: {
rules: [{
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {}
// other vue-loader options go here
}
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]'
}
}
]
},
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js',
},
extensions: ['*', '.js', '.vue', '.json']
},

devServer: {
proxy: {
'/api': {
target: 'http://localhost:3000'
}
},
historyApiFallback: true,
noInfo: true
},
performance: {
hints: false
},
devtool: '#eval-source-map'
}

if (process.env.NODE_ENV === 'production') {
module.exports.devtool = '#source-map'
// http://vue-loader.vuejs.org/en/workflow/production.html
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false
}
}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
])
}

我的 webpack 有问题吗?我做错了什么?有人可以帮我吗?

最佳答案

更改自

  new webpack.optimize.UglifyJsPlugin()

const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
[...]

new UglifyJSPlugin()

使用 npm install --save uglifyjs-webpack-plugin修复它。 https://github.com/webpack/webpack/issues/5858#issuecomment-338430720

关于javascript - UglifyJs 中的 build.js 中出现错误 意外 token : punc ((),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50184201/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com