Angular CLI Webpack (ngw)
This package provides an opportunity to modify @angular/cli project's webpack configuration without "ejecting".
For angular 6/7:
$ npx -p @angular/cli ng new my-project && cd my-project # create new Angular CLI project$ npm i -D ngw # installing an improved cli-eject$ ./node_modules/.bin/ngw --set-up # run via terminal in project rootSet up went successfully!
For angular 5 use
npm i -D ngw@angular5
Last command installation (ngw --set-up) makes three things:
- Changes scripts in package.json that starts from
- Creates file
ngw.config.tsin project root where you can redefine
complierOptions.module = "commonjs"property in
So just make changes to the webpack config in appeared
You may like to do
npm i -D @types/webpack for better experience.
Removes unused selectors from your CSS
This little piece of code in your ngw.config removes unused selectors from your CSS:
You may like to debug your configuration. This can be done with ndb package.
- Make sure that your development environment meets the requirements of
npm i -g ndb
ndb npm run start
Prod and dev mode modifications (ngw.config.ts)