我对 Angular 的配置很陌生,对构建器不太了解。我正在遵循有关 如何在 Angular 中使用 process.env 的教程,它必须更改 angular.json
中的一些配置。当我执行
ng serve
时出现错误,即
发生未处理的异常:找不到模块 '@angular-builders/custom-webpack/dist/package.json'我有两个问题。请看一下我的 angular.json,特别是
projects.architect.serve
"build": {
"builder": "@angular-builders/custom-webpack/dist:browser",
"options": {
"customWebpackConfig": {
"path": "src/custom-webpack.config.ts"
},
"outputPath": "dist/fitness-proj",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": [
"zone.js"
],
"tsConfig": "tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.css"
],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "FitnessProj:build:production"
},
"development": {
"browserTarget": "FitnessProj:build:development"
}
},
"defaultConfiguration": "development"
},
ng serve
或
ng update
时,它都会给我上面引用的错误。当我
ng serve
时,我还需要做其他事情来更新构建器吗?
└── @angular-builders/
└── custom-webpack/
├── dist/
│ ├── browser/
│ │ └── // a bunch of files
│ └── dev-server/
│ └── // a bunch of files
├── node_modules
├── builders.json
└── package.json
我想使用自定义 webpack,特别是开发服务器。 1 阻止我这样做,而且我不知道应该在“构建器”和代码的其他部分中放入什么来使用特定的构建器,以便(最终目标)process.env 工作.
如果有人可以帮助我,那就太好了,我将非常感激。提前致谢。