我有一個Angular 4應用程序。Angular 4,意外的令牌:在ng構建期間的名稱(主題) - 產品
我可以成功地建立與ng build
的項目,但是,當我運行ng build --prod
以下錯誤被拋出。
在vendor.4008cf7dff2b98412878.bundle.js ERROR從UglifyJs 意外標記:名稱(主題) [vendor.4008cf7dff2b98412878.bundle.js:19471,6]
當我做了一些研究,我看到uglifyjs不能與es6一起工作,而我在tsconfig文件中將目標更改爲es5。
但我不斷收到此錯誤。
我不明白什麼是錯的。
這裏是角CLI版本
這裏是我的tsconfig.json文件
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2016",
"dom"
],
"paths": {
"@angular/*": [
"../node_modules/@angular/*"
]
}
}
}
這裏是我的角cli.json文件
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "myapp"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"styles.css",
"../node_modules/sweetalert2/dist/sweetalert2.css",
"../node_modules/ladda/dist/ladda-themeless.min.css"
],
"scripts": [
"../node_modules/crypto-js/crypto-js.js",
"../src/assets/js/jquery-2.1.1.js",
"../src/assets/js/plugins/datatables/jquery.dataTables.min.js",
"../src/assets/js/plugins/datatables/dataTables.fixedColumns.min.js",
"../src/assets/js/bootstrap.min.js",
"../src/assets/js/plugins/metisMenu/jquery.metisMenu.js",
"../src/assets/js/plugins/mask/jquery.mask.min.js",
"../src/assets/js/plugins/slimscroll/jquery.slimscroll.min.js",
"../src/assets/js/plugins/chartJs/Chart.min.js",
"../src/assets/js/plugins/toastr/toastr.min.js",
"../src/assets/js/plugins/datepicker/bootstrap-datepicker.js",
"../src/assets/js/plugins/datepicker/bootstrap-datepicker.tr.js",
"../src/assets/js/plugins/datetimepicker/jquery.datetimepicker.full.min.js",
"../src/assets/js/plugins/iCheck/icheck.min.js",
"../src/assets/js/plugins/chosen/chosen.jquery.min.js",
"../src/assets/js/plugins/jsTree/jstree.min.js",
"../src/assets/js/plugins/nestable/jquery.nestable.js",
"../src/assets/js/plugins/colorpicker/bootstrap-colorpicker.min.js",
"../src/assets/js/jasny-bootstrap.min.js",
"../src/assets/js/inspinia.js",
"../src/assets/js/custom.js"
],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"project": "src/tsconfig.app.json",
"exclude": "**/node_modules/**"
},
{
"project": "src/tsconfig.spec.json",
"exclude": "**/node_modules/**"
},
{
"project": "e2e/tsconfig.e2e.json",
"exclude": "**/node_modules/**"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "css",
"component": {}
}
}