diff --git a/.travis.yml b/.travis.yml index d2c0283..34b00bb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,25 @@ +os: + - linux language: node_js -sudo: false +sudo: true node_js: - - "9.3" + - "10.12" install: - - npm install + - npm i + - npm run build + - rm -rf ./node_modules + - npm i --production +before_script: + - npm i -g @angular/cli + - set -e + - cp -rf "$PWD" ~/ngw + - cd ~ + - ng new test-project --skip-install --defaults=true + - cd test-project + - npm i + - cp -rf "../ngw" "./node_modules/ngw" + - ln -sr "./node_modules/ngw/bin/ngw" "./node_modules/.bin/ngw" script: - - npm run lint - - npm test - - npm build -after_success: - - npm run coverage + - "grep 'angular.*: \"' package-lock.json | sort -u" + - ./node_modules/.bin/ngw --set-up + - npm run build | fgrep ngw.config diff --git a/README.md b/README.md index 2a133a5..64085b0 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Coverage Status](https://coveralls.io/repos/github/Angular-RU/angular-cli-webpack/badge.svg?branch=master)](https://coveralls.io/github/Angular-RU/angular-cli-webpack?branch=master) [![Coverage Status](https://img.shields.io/npm/dt/ngw.svg)](https://npm-stat.com/charts.html?package=ngw&from=2017-01-12) ## Installation -For angular 6: +For angular 6/7: ```bash $ 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 @@ -15,9 +15,10 @@ Set up went successfully! ``` For angular 5 use `npm i -D ngw@angular5` ## Usage: -Last command installation (ngw --set-up) makes two things: +Last command installation (ngw --set-up) makes three things: 1) Changes scripts in package.json that starts from `ng ` to `ngw ` 2) Creates file `ngw.config.ts` in project root where you can redefine `webpack.Configuration` used by `@angular/cli` +3) Sets `compilerOptions.module = "commonjs"` property in `tsconfig.json` So just make changes to the webpack config in appeared `ngw.config.ts` @@ -43,24 +44,26 @@ export default function(config) { return config; } ``` +## Debugging +You may like to debug your configuration. +This can be done with [ndb](https://github.com/GoogleChromeLabs/ndb) package. +1) Make sure that your development environment meets the requirements of `ndb` +2) `npm i -g ndb` +3) Add `debugger` keyword in `ngw.config.ts` +4) `ndb npm run start` -#### Prod and dev mode modifications (ngw.config.ts) - +## Prod and dev mode modifications (ngw.config.ts) ```typescript + +const isProduction = process.argv.indexOf('--prod') !== -1; + export default function(config, options) { //common config modification ... - switch(options.buildOptions.enviroment) { - case 'prod': - config = productionModificationsMerged(config); - break - case 'dev': - //etc + config = isProduction + ? productionModificationsMerged(config) + : devModificationsMerged(config); } + ... } ``` - - -## Caution - -For complex cases it's more appropriate to use `ng eject` command. Default building process could be changed significanlty in further `@angular/cli` releases so your customization could break (or became broken). diff --git a/package.json b/package.json index 91b560a..accd0bb 100644 --- a/package.json +++ b/package.json @@ -26,11 +26,11 @@ "homepage": "https://github.com/Angular-RU/ngw#readme", "peerDependencies": { "@types/node": "*", - "@types/webpack": "*", - "typescript": "^3.0.0" + "@types/webpack": "*" }, "dependencies": { - "ts-node": "^7.0.1" + "ts-node": "^7.0.1", + "typescript": "^3.0.0" }, "devDependencies": { "@angular-devkit/build-angular": "0.6.7", @@ -38,7 +38,6 @@ "@types/node": "^9.4.6", "@types/webpack": "^3.0.0", "tslint": "^5.8.0", - "tslint-config-standard": "^7.0.0", - "typescript": "^2.7.2" + "tslint-config-standard": "^7.0.0" } }