Skip to content Skip to sidebar Skip to footer

Angularclass/angular2-webpack-starter : Exclude Mock Files From Webpack Config For Prod Builds

I'm using the AngularClass/angular2-webpack-starter and I've been struggling with its webpack configuration for a while, although what I want to achieve seems very simple. Basicall

Solution 1:

Context: angular2-webpack-starter

The assets folder recopy during the build task is handle by a webpack plugin aka CopyWebpackPlugin. By default it is only setup in the webpack.common.js. To achieve what you are trying to, you should put the same task in both of your environments. That way you would be able to exclude the unwanted files.

  1. webpack.common.js

    new CopyWebpackPlugin([
      { from: 'src/meta'}
    ])
    
  2. webpack.dev.js

    new CopyWebpackPlugin([
      { from: 'src/assets', to: 'assets' }
    ])
    
  3. webpack.prod.js

    new CopyWebpackPlugin([
      { from: 'src/assets', to: 'assets', ignore: ['mock/data/*'] }
    ])
    

Post a Comment for "Angularclass/angular2-webpack-starter : Exclude Mock Files From Webpack Config For Prod Builds"