Skip to content

How to use css chunks integration

Asad Sahi edited this page Jul 19, 2016 · 4 revisions

Make sure all your components are including their stylesheets using require as such:

@Component
styles: [require(./app.css)]

Note that component's styleUrl will not work as it expects a URI.

If you are using global style sheets, you can include them in your app as well:

@Component
  styles: [ require('./app.css'),
      require('../../node_modules/ng2-material/dist/ng2-material.css'),
      require('../../node_modules/ng2-material/dist/font.css') ]

After a successful production build (npm run build:prod). The index file in the build directory will contain a reference to the compiled CSS files gathered under the name styles.css.

also see https://github.com/AngularClass/angular2-webpack-starter/pull/338