Angular 2 Web application for the Mesomeds delivery pilot
Note this project requires node v4.x.x or higher and npm 2.14.7 but in order to be able to take advantage of the complete functionality we strongly recommend node >=v6.5.0 and npm >=3.10.3.
Here is how to speed-up the build on Windows.
In order to start the seed use:
$ git clone --depth 1 https://github.com/mgechev/angular-seed.git
$ cd angular-seed
# install the project's dependencies
$ npm install
# fast install (via Yarn, https://yarnpkg.com)
$ yarn install # or yarn
# watches your files and uses livereload by default
$ npm start
# api document for the app
# npm run build.docs
# generate api documentation
$ npm run compodoc
$ npm run serve.compodoc
# to start deving with livereload site and coverage as well as continuous testing
$ npm run start.deving
# dev build
$ npm run build.dev
# prod build, will output the production application in `dist/prod`
# the produced code can be deployed (rsynced) to a remote server
$ npm run build.prod
# dev build of multiple applications (by default the value of --app is "app")
$ npm start -- --app baz
$ npm start -- --app foo
$ npm start -- --app bar
Does not rely on any global dependencies.
Note that AoT compilation requires node v6.5.0 or higher and npm 3.10.3 or higher.
In order to start the seed with AoT use:
# prod build with AoT compilation, will output the production application in `dist/prod`
# the produced code can be deployed (rsynced) to a remote server
$ npm run build.prod.aot
This application provides full support for tree-shaking your production builds with Rollup, which can drastically reduce the size of your application. This is the highest level of optimization currently available.
To run this optimized production build, use:
# prod build with AoT compilation and Rollup tree-shaking, will output the production application in `dist/prod`
# the produced code can be deployed (rsynced) to a remote server
$ npm run build.prod.rollup.aot
Your project will be compiled ahead of time (AOT), and then the resulting bundle will be tree-shaken and minified. During the tree-shaking process Rollup statically analyses your code, and your dependencies, and includes the bare minimum in your bundle.
Notes
- Beware of non-static/side-effectful imports. These cannot be properly optimized. For this reason, even though tree-shaking is taking place the developer still needs to be careful not to include non-static imports that are unnecessary, as those referenced imports will always end up in final bundle. Special attention should be given to RxJs, which makes heavy use of non-static/side-effectful imports: make sure you only add the operators you use, as any added operators will be included in your final production bundle.
- UMD modules result in code that cannot be properly optimized. For best results, prefer ES6 modules whenever possible. This includes third-party dependencies: if one is published in both UMD and ES6 modules, go with the ES6 modules version.
- During a production build, CommonJs modules will be automatically converted to ES6 modules. This means you can use them and/or require dependencies that use them without any issues.
The application provides full Docker support. You can use it for both development as well as production builds and deployments.
The Dockerization infrastructure is described in the docker-compose.yml
(respectively docker-compose.production.yml
.
The application consists of two containers:
angular-seed
- In development mode, this container serves the angular app. In production mode it builds the angular app, with the build artifacts being served by the Nginx containerangular-seed-nginx
- This container is used only production mode. It serves the built angular app with Nginx.
Run the following:
$ docker-compose build
$ docker-compose up -d
Now open your browser at http://localhost:5555
Run the following:
$ docker-compose -f docker-compose.production.yml build
$ docker-compose -f docker-compose.production.yml up angular-seed # Wait until this container has finished building, as the nginx container is dependent on the production build artifacts
$ docker-compose -f docker-compose.production.yml up -d angular-seed-nginx # Start the nginx container in detached mode
Now open your browser at http://localhost:5555
- How to start
- How to start with Aot
- Tree-shaking with Rollup
- Dockerization
- Table of Content
- Configuration
- Environment Configuration
- Tools documentation
- How to extend?
- Running tests
- Advanced Seed Option
- Contributors
- License
Default application server configuration
var PORT = 5555;
var LIVE_RELOAD_PORT = 4002;
var DOCS_PORT = 4003;
var APP_BASE = '/';
Configure at runtime
$ npm start -- --port 8080 --reload-port 4000 --base /my-app/
If you have different environments and you need to configure them to use different end points, settings, etc. you can use the files dev.ts
or prod.ts
in./tools/env/
. The name of the file is environment you want to use.
The environment can be specified by using:
$ npm start -- --env-config ENV_NAME
Currently the ENV_NAME
s are dev
, prod
, staging
, but you can simply add a different file "ENV_NAME.ts".
file in order to alter extra such environments.
A documentation of the provided tools can be found in tools/README.md.
Visit the Wiki page of the project.
### Work with the AWNICS DEVELOP
# Pull the upstream repository
git remote add upstream-awn https://github.com/AWNICS/mesomeds-ng2.git
git pull upstream-awn master
# Start working with the develop branch with a pull-merge
git checkout develop
git pull upstream-awn develop
# Commit and push branches to your origin
git add .
git commit -m "Updated the code" --author="Rahul Vishwakarma <[email protected]>"
git push origin develop
git push origin master
# Create a pull request for AWNICS repo fron your forked branch
# Build
npm install (and all other usage docs in this `README` apply).
$ npm test
# Development. Your app will be watched by karma
# on each change all your specs will be executed.
$ npm run test.watch
# NB: The command above might fail with a "EMFILE: too many open files" error.
# Some OS have a small limit of opened file descriptors (256) by default
# and will result in the EMFILE error.
# You can raise the maximum of file descriptors by running the command below:
$ ulimit -n 10480
# code coverage (istanbul)
# auto-generated at the end of `npm test`
# view coverage report:
$ npm run serve.coverage
# e2e (aka. end-to-end, integration) - In three different shell windows
# Make sure you don't have a global instance of Protractor
# Make sure you do have Java in your PATH (required for webdriver)
# npm install webdriver-manager <- Install this first for e2e testing
# npm run webdriver-update <- You will need to run this the first time
# node ./node_modules/protractor/bin/webdriver-manager update
$ npm run webdriver-start
$ npm run serve.e2e
$ npm run e2e
# e2e live mode - Protractor interactive mode
# Instead of last command above, you can use:
$ npm run e2e.live
You can learn more about Protractor Interactive Mode here
An advanced option to this seed exists here which mirrors the latest changes here but adds core support for:
- ngrx/store RxJS powered state management, inspired by Redux
- ngrx/effects Side effect model for @ngrx/store
- ng2-translate for i18n
- Usage is optional but on by default
- Up to you and your team how you want to utilize it. It can be easily removed if not needed.
- angulartics2 Vendor-agnostic analytics for Angular applications.
- Out of box support for Segment
- When using the seed, be sure to change your
write_key
here
- When using the seed, be sure to change your
- Can be changed to any vendor, learn more here
- Out of box support for Segment
- lodash Helps reduce blocks of code down to single lines and enhances readability
- NativeScript cross platform mobile (w/ native UI) apps. Setup instructions here.
- Electron cross platform desktop apps (Mac, Windows and Linux). Setup instructions here.
You may use it to learn how to extend this seed for your own use cases or use the advanced seed if your project needs those features.
- Rahul Vishwakarma
- Arun Gadag
MIT