TommyF
TommyF

Reputation: 7140

@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?

Upvotes: 12

Views: 6407

Answers (1)

Alessandro Prete
Alessandro Prete

Reputation: 460

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" }
            ]
          }
        }
      }
    }
}

Upvotes: 25

Related Questions