当前正在使用.NET Core 2.0,Angular 6并使用VS2017作为我的编辑器。
Webpack 4.16.3不遵守package.json文件中的模式设置。
这是我的package.json文件
"scripts": {
"dev": "webpack --mode development",
"build": "webpack --mode production"
},
"devDependencies": {
"@angular/animations": "6.1.0",
"@angular/cli": "^6.1.1",
"@angular/common": "6.1.0",
"@angular/compiler": "6.1.0",
"@angular/compiler-cli": "6.1.0",
"@angular/core": "6.1.0",
"@angular/forms": "6.1.0",
"@angular/http": "6.1.0",
"@angular/platform-browser": "6.1.0",
"@angular/platform-browser-dynamic": "6.1.0",
"@angular/platform-server": "6.1.0",
"@angular/router": "6.1.0",
"@ngtools/webpack": "^6.1.1",
"@types/chai": "4.1.4",
"@types/jasmine": "2.8.8",
"@types/webpack-env": "1.13.6",
"angular2-router-loader": "0.3.5",
"angular2-template-loader": "0.6.2",
"aspnet-prerendering": "^3.0.1",
"aspnet-webpack": "^3.0.0",
"awesome-typescript-loader": "5.2.0",
"bootstrap": "4.1.3",
"chai": "4.1.2",
"css": "2.2.3",
"css-loader": "1.0.0",
"es6-shim": "0.35.3",
"event-source-polyfill": "0.0.12",
"expose-loader": "0.7.5",
"extract-text-webpack-plugin": "3.0.2",
"file-loader": "1.1.11",
"html-loader": "0.5.5",
"isomorphic-fetch": "2.2.1",
"jasmine-core": "3.1.0",
"jquery": "3.3.1",
"json-loader": "0.5.7",
"karma": "2.0.5",
"karma-chai": "0.1.0",
"karma-chrome-launcher": "2.2.0",
"karma-cli": "1.0.1",
"karma-jasmine": "1.1.2",
"karma-webpack": "3.0.0",
"popper.js": "^1.12.9",
"preboot": "6.0.0-beta.4",
"raw-loader": "0.5.1",
"reflect-metadata": "0.1.12",
"rxjs": "6.2.2",
"style-loader": "0.21.0",
"to-string-loader": "1.1.5",
"typescript": "2.9.2",
"url-loader": "1.0.1",
"webpack": "^4.16.3",
"webpack-cli": "^3.1.0",
"webpack-hot-middleware": "2.22.3",
"webpack-merge": "4.1.3",
"zone.js": "0.8.26"
},
"dependencies": {
"@ng-bootstrap/ng-bootstrap": "^2.2.0",
"ng-bootstrap": "^1.6.3",
"ngx-loading": "^1.0.14",
"ngx-pagination": "^3.1.1",
"npm": "^6.2.0",
"w3-css": "^4.1.0"
}
当我运行该应用程序时,构建速度是webpack版本为Vpack〜V3时的两倍。 这是来自控制台的警告:
[HMR]捆绑包有4条警告 client.js:189配置 尚未设置“模式”选项,Webpack将为此值回退到“生产”状态。将“模式”选项设置为“开发”或“生产”以启用每个环境的默认设置。 您也可以将其设置为“ none”以禁用任何默认行为。了解更多:https://webpack.js.org/concepts/mode/ 资产大小限制:以下资产超过了建议的大小限制(244 KiB)。 这可能会影响网络性能。 资产: main-client.js(1.2 MiB) 0.0338b4a2c00f8368abd9.hot-update.js(810 KiB) 入口点大小限制:以下入口点的组合资产大小超过了建议的限制(244 KiB)。这可能会影响网络性能。 入口点: 主要客户(2 MiB) main-client.js 0.0338b4a2c00f8368abd9.hot-update.js webpack性能建议: 您可以使用import()来限制捆绑包的大小,也可以要求确保延迟加载应用程序的某些部分。 有关更多信息,请访问https://webpack.js.org/guides/code-splitting/
请让我知道如何在webpack〜4中正确设置模式。