Mat*_*lez 16 angular-cli angular
如何使用angular-cli从角度构建中排除文件.我只是在tsconfig.json和tsconfig.app.json文件中添加要排除的路径,但是当我运行时ng serve,angular仍在尝试编译文件.
有任何想法吗?
Rom*_*n C 10
使用(在根级别)的exclude属性tsconfig.json,即:
{
"exclude": [
"node_modules",
"**/*.spec.ts"
]
}
Run Code Online (Sandbox Code Playgroud)
小智 7
在您的 angular.json 文件中,按如下方式编辑构建部分:
...
"assets": [
"src/assets",
"src/favicon.ico"
],
"styles": [
"src/styles.scss"
],
"scripts": []
},
"configurations": {
"production": {
"assets": [
{
"glob": "**/*",
"input": "src/assets/",
"ignore": [
"**/test.json",
"**/test"
],
"output": "/assets/"
},
{
"glob": "favicon.ico",
"input": "src/",
"output": "/"
}
],
...
Run Code Online (Sandbox Code Playgroud)
这仍然会执行所需的默认导入,但在运行 ng build --prod 时删除指定的文件/目录(test.json & /test),但是它们仍然可以通过 ng serve 使用,这对本地开发非常有用。
.gitignore如果这些文件中有敏感信息,请记住也要排除在您的文件中。
编辑时我无法让它工作tsconfig.json,但上面的工作就像一个魅力!
基于此处找到的示例的解决方案
| 归档时间: |
|
| 查看次数: |
11233 次 |
| 最近记录: |