gpt4 book ai didi

angular - 忽略 ng build --prod 中的 `assets` 文件夹

转载 作者:太空狗 更新时间:2023-10-29 17:52:01 26 4
gpt4 key购买 nike

我不想在 assets 文件夹中包含

ng build --prod

但是 assets 文件夹在我运行时应该可用

ng serve

我试着写如下:

apps:[
exclude: ["assets"]
]

但这没有用。也尝试了下面的解决方案

https://github.com/angular/angular-cli/issues/5435

但是这些都不起作用。任何帮助将不胜感激。

最佳答案

我有一个非常相似的场景,因为我不想在使用 aot 构建时复制 Assets 文件夹。找到this article后,我最终在 .angular-cli.json 复制了我的应用程序配置,每个配置都有其唯一的名称(在我的例子中是 devAppaotApp),如下所示:

"$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 也可以),当我需要生成用于生产的 bundle ,我运行 ng build --app aotApp --prod

关于angular - 忽略 ng build --prod 中的 `assets` 文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44795360/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com