Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to tell angular-cli (for angular 2) to generate minified version of css?

Tags:

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'     ]   }); }; 
like image 565
Donovant Avatar asked Aug 04 '16 09:08

Donovant


People also ask

Does ng build minify?

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).

What is bundling and minification in angular?

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.

What is bundling in Angular?

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.


1 Answers

ng build --prod --env=prod 

or

ng serve --prod 

Will minify and add a file hash for you.

  • the --prod tells it to minify hash, and gzip.
  • the --env=prod tells it to use your prod environment constants file.

which would look like this

like image 188
James Avatar answered Sep 22 '22 19:09

James