Ignore `assets` folder from ng build -prod
I want not to include the assets
folder in
ng build --prod
But the folder assets
should be available when I run
ng serve
I have tried writing like below:
apps:[
exclude: ["assets"]
]
But it didn't work. Tried the solution as below,
https://github.com/angular/angular-cli/issues/5435
But none of them work. Any help would be appreciated.
source to share
I had a very similar scenario as I didn't want to copy the assets folder when building using aot. After finding this article , I ended up duplicating my application configuration in .angular-cli.json, each with its own unique name (in my case devApp and aotApp) as follows:
"$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
So ... for development I use ng serve --app devApp
(although it only seems to work ng serve
) and when I need to generate packages to build I run ng build --app aotApp --prod
.
source to share