Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@angular/cli build exclude assets subdirectory for --prod

I have test data located under assets/test/ that I don't want to be included in a production deployment.

How do I configure @angular/cli to ignore / exclude that folder when running ng build --prod?
Adding an exclude section to the tsconfig.json as suggested elsewhere did not result in any observable change (i.e. the files where still under dist/assets/test after ng build --prod was run).

"compilerOptions": { ... },
"exclude" : [ "src/assets/test" ]

Is tere another way to properly exclude certain files or folders from the ng build process?

like image 906
TommyF Avatar asked Jul 27 '17 12:07

TommyF


1 Answers

Maybe a little too late, anyway you can get the behaviour you desire by specifiyng the assets content as a glob in your angular.json file:

"projects": {
    "myapp": {
      "architect": {
        "build": {
          "options": {
            "assets": [
              { "glob": "**/*", "input": "src/assets", "ignore": ["**/test/*"], "output": "/assets" }
            ]
          }
        }
      }
    }
}
like image 54
Alessandro Prete Avatar answered Sep 27 '22 17:09

Alessandro Prete