A template for building Angular applications or re-usable Angular modules that you can publish to npm. This template is compatible with Angular 6.
For an Angular 5 compatible template, see ng-module-template version 5.
git clone https://github.com/angular-patterns/ng-module-template.git
cd ng-module-template
npm install
Opens webpack-dev-server on port 8080 for development:
npm run dev
npm run build-module
Production distribution files may be found in the dist
folder.
There are five type of tests:
- Unit Tests -
npm run test
- e2e Tests -
npm run e2e
- lint Tests -
npm run lint
- Code Metrics -
npm run metrics
- Size Report -
npm run build
All reports are stored under the reports
folder.
You have two options for a production build:
-
Angular Application - outputs to the
dist
folder.
npm run build
-
Reusable Angular Module - outputs to the
dist
folder.
npm run build-module
a. Specifying a Module to Package
Modify src\public_api.ts and overwrite the export statements:
export * from './src/app/my/my.module.ts
export * from './src/app/my/my.component.ts
Note: Remember to rebuild before publishing (i.e. npm run build
or npm run build-module
)
npm run name-module -- --name <my-module>
npm add *
npm commit -m "renamed module"
There are two options for deployment.
- Publish to local file system
npm run publish-local
- publishes from thedist
folder toc:\packages
.
The folder can be customized using a dest
parameter:
npm run publish-local -- --dest c:\path\to\my-module
- Publish to npm
npm publish
Follow the publish instructions from npm: https://docs.npmjs.com/getting-started/publishing-npm-packages
If you published locally:
npm install c:\path\to\my-module --save
If you published to npm:
npm install my-module --save