As the title says, when I run "ng serve" angular-cli generates normal css whereas I expect to get the minified version. Is there any specific setting to use for angular-cli-build, or some additional plugin to install and use?
This is my angular-cli-build.js
var Angular2App = require('angular-cli/lib/broccoli/angular2-app'); module.exports = function(defaults) { return new Angular2App(defaults, { vendorNpmFiles: [ 'systemjs/dist/system-polyfills.js', 'systemjs/dist/system.src.js', 'zone.js/dist/**/*.+(js|js.map)', 'es6-shim/es6-shim.js', 'reflect-metadata/**/*.+(ts|js|js.map)', 'rxjs/**/*.+(js|js.map)', '@angular/**/*.+(js|js.map)', 'angular2-cookie/**/*.js' ] }); };
ng build creates a build in the dist folder using webpack. The dist folder is published to your production website and contains everything needed to run your website (the minified Angular framework, your code, and dependencies referenced in the application).
So, minification and bundling are actually interrelated processes that help to reduce the size of the js file to get downloaded faster in the browser and giving a pleasant experience to the user. These are the basic pillar of the Angular framework when it comes to increasing the overall performance of the application.
To understand how bundling works in an Angular app, you don't need to look further than the angular. json file. The angular. json file that is generated for your Angular app is the configuration file that is used by the underlying build system contained within the Angular CLI.
ng build --prod --env=prod
or
ng serve --prod
Will minify and add a file hash for you.
--prod
tells it to minify hash, and gzip.--env=prod
tells it to use your prod environment constants file.which would look like this
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With