Me and my team recently shifted to Angular2 (or AngularJS 2) from AngularJS 1.x. We used to use Yeoman Angular Generator for scaffolding and grunt
for building and creating a war using the inbuilt gruntfile.js that used to get created by default with the above mentioned generator. We used it by making some minor changes to it and we were good to go.
What this file essentially does is:
- It combines all third party dependency js files installed from package.json in node_modules folder (i.e.
npm install
) & optionally even from bower.json in bower_components folder(i.e.bower install
) [if you are using it] into a single vendor.js file (Does so by doing concatenation, minification and uglification) - It repeats the above steps for css files and combines it into vendor.css
- It combines all user javascript files into scripts.js and css files in styles.css
- In bundles these 4 files with index.html and other necessary things like images, fonts, etc.
I have been looking for a similar solution for Angular2 but have failed so far. I tried using gulp
by using gulpfile.js found in angular2-seed project or ng build
from angular-cli project but none have provided such a solution.
The problem always occurs with the node_modules folder. The typescript ts files from these folders which are completely unnecessary get built into the bundle.
Now I do understand that Angular2 is different from Angular1 and all but how can build a good build by in this? What approach should I take? And can I achieve anything like what I used to get in Angular1?