我不想在
中加入assets
文件夹
ng build --prod
但我正在运行时assets
文件夹可用
ng serve
我尝试写作如下:
apps:[
exclude: ["assets"]
]
但是这没用。 尝试解决方案如下
https://github.com/angular/angular-cli/issues/5435
但它都不起作用。任何帮助将不胜感激。
答案 0 :(得分:5)
我有一个非常类似的场景,因为我不想在使用aot构建时复制assets文件夹。 找到this article后,我最终在.angular-cli.json上复制了我的应用配置,每个都有一个唯一的名称(在我的情况下是 devApp 和 aotApp )像这样:
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "my-project"
},
"apps": [
{
"name": "devApp",
"root": "src",
"outDir": "wwwroot",
"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.scss"
],
"scripts": [
],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
,
{
"name": "aotApp",
"root": "src",
"outDir": "wwwroot",
"assets": [
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"styles.scss"
],
"scripts": [
],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
--- and then the rest of the configuration
所以...开发我使用ng serve --app devApp
(虽然看起来只有ng serve
也有效),当我需要为生产生成包时,我运行ng build --app aotApp --prod
。
答案 1 :(得分:0)
在angular-cli.json文件中添加资产,以便在键入ng build时将生产中的资产文件夹排除在外 - 如下所示
"apps": [
{
"root": "src",
"outDir": "AngularApp",
"assets": [
],
}
]
ng serve
资产文件夹将可用