当我使用./
构建ckeditor时./node_modules/.bin/webpack --mode development
一切正常,但是当我尝试使用
进行构建时./node_modules/.bin/webpack --mode production
我收到此错误:
./node_modules/@ckeditor/ckeditor5-utils/src/ckeditorerror.js中的错误 模块构建失败(来自 ./node_modules/@ckeditor/ckeditor5-dev-webpack-plugin/lib/translatesourceloader.js): 语法错误:意外令牌(13:19)@ ./node_modules/@ckeditor/ckeditor5-core/src/editor/utils/elementapimixin.js 6:0-72 33:13-26 @ ./node_modules/@ckeditor/ckeditor5-editor-classic/src/classiceditor.js 来自UglifyJs的bundle.js中的@ ./app.js错误意外令牌:关键字 (常量) [./node_modules/@ckeditor/ckeditor5-utils/src/log.js:46,0][bundle.js:160,0]
我可以编辑ckeditor文件并删除const字,但是随后它会在包含导出const的下一个文件中出错。
她是我使用的uglify-js版本:
"uglify-js": { "version": "3.4.9", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.9.tgz", "integrity": "sha512-8CJsbKOtEbnJsTyv6LE6m6ZKniqMiFWmm9sRbopbkGs3gMPPfd3Fh8iIA4Ykv5MgaTbqHr4BaoGLJLZNhsrW1Q==", "dev": true, "requires": { "commander": "~2.17.1", "source-map": "~0.6.1" } }, "uglifyjs-webpack-plugin": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-2.0.1.tgz", "integrity": "sha512-1HhCHkOB6wRCcv7htcz1QRPVbWPEY074RP9vzt/X0LF4xXm9l4YGd0qja7z88abDixQlnVwBjXsTBs+Xsn/eeQ==", "dev": true, "requires": { "cacache": "^11.2.0", "find-cache-dir": "^2.0.0", "schema-utils": "^1.0.0", "serialize-javascript": "^1.4.0", "source-map": "^0.6.1", "uglify-js": "^3.0.0", "webpack-sources": "^1.1.0", "worker-farm": "^1.5.2" } },
-更新- 我通过从webpack.conf.js中删除它来修复了它
optimization: {
minimizer: [
new UglifyJsWebpackPlugin( {
sourceMap: true,
uglifyOptions: {
output: {
// Preserve CKEditor 5 license comments.
comments: /^!/
}
}
} )
]
},
答案 0 :(得分:0)
我也遇到了这个问题。我切换到terser-webpack-plugin并可以成功构建。
https://github.com/webpack-contrib/uglifyjs-webpack-plugin/issues/362