Zachary Woolever
Zachary Woolever

Reputation: 21

Angular2 - Removing Dev libraries from build

I have two libraries which i use in my angular application that are great for local development but should not go up into our production builds.

The two libraries are angular-in-memory-web-api and @ngrx/store-devtools

These libraries must be imported into the app.module

Is there a way to have these two imports removed when i go to make a production build or do i need to keep removing them manually on release?

Upvotes: 1

Views: 139

Answers (2)

Zachary Woolever
Zachary Woolever

Reputation: 21

I solved this using the angular cli environments files.

I was able to create an Environment Module that i could import into the app.module which contains all the development libraries.

Upvotes: 1

Caleb Macdonald Black
Caleb Macdonald Black

Reputation: 1572

You should be installing them as dev dependencies using 'npm install pkg --dev' then I imagine a production build would not include those depencies 'ng build --prod'.

Maybe you could import these into environment.dev.ts and access the environment.ts file from your app.module.ts. In you environment.prod.ts just leave these imports out and have your app.module.ts not use them if it returns undefined from environment.ts

Upvotes: 0

Related Questions