意外标记:来自 UglifyJs 的运算符 (>) [英] Unexpected token: operator (>) from UglifyJs
问题描述
我有 2 个 Vue-Cli webpack 项目(ClientApp 和 Lib).lib是我的组件库(与其他项目共享)
I have 2 Vue-Cli webpack projects (ClientApp and Lib). Lib is my components library (shared with other projects)
当我构建我的项目 ClientApp npm run build
时,出现以下错误:
When I build my project ClientApp npm run build
, I have the following error:
ERROR in static/js/app.d08a24ce0e8d0438ce68.js from UglifyJs
Unexpected token: operator (>) [C:/.../Lib/src/tools/escape-key.js:3,0][static/js/app.d08a24ce0e8d0438ce68.js:17468,38]
问题
错误似乎来自文件 escape-key.js
中的箭头函数.这是 ES6 语法,UglifyJS 无法解析.在 Uglify 之前,Babel 不应该先走吗?请注意,它适用于 *.vue
文件.
Questions
It seems like the error comes from an arrow function in the file escape-key.js
.
This is ES6 syntax and UglifyJS can't parse this.
Shouldn't Babel go first, before Uglify?
Note that is works well with *.vue
files.
ClientApp
| - build
| - config
| - src
| - App.Vue // import EscapeKey from '~lib/tools/escape-key';
Lib
| -src
| - tools
| - escape-key.js
ClientApp 的 webpack.base.conf.js 文件
请注意,Lib 有一个别名.
ClientApp's webpack.base.conf.js file
Note there is an alias to Lib.
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'@': resolve('src'),
'~lib': path.join(__dirname, '../../lib/src'),
}
},
如有需要,请随时询问更多详情.
Please feel free to ask for more details if required.
推荐答案
更改我的 babel-loader 配置后,它起作用了.
After changing my babel-loader config, it worked.
{
test: /.js$/,
loader: 'babel-loader',
include: [path.join(__dirname, '../../Lib/src'), resolve('src'), resolve('test')]
}
这篇关于意外标记:来自 UglifyJs 的运算符 (>)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!