Skip to content
This repository has been archived by the owner on Sep 11, 2018. It is now read-only.

Commit

Permalink
Merge pull request #80 from davezuko/fix/extract-text-plugin
Browse files Browse the repository at this point in the history
fix(webpack): CSS is now only extracted during production builds
  • Loading branch information
David Zukowski committed Sep 13, 2015
2 parents 9af6153 + c92fe63 commit a7c3513
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions build/webpack/client.js
Expand Up @@ -48,11 +48,12 @@ const webpackConfig = {
},
{
test : /\.scss$/,
loader : ExtractTextPlugin.extract('style-loader', [
loaders : [
'style-loader',
'css-loader',
'autoprefixer?browsers=last 2 version',
'sass-loader?includePaths[]=' + paths.src('styles')
].join('!'))
]
}
]
},
Expand Down Expand Up @@ -93,11 +94,21 @@ if (globals.__DEV__) {
}

if (globals.__PROD__) {

// Compile CSS to its own file in production.
webpackConfig.module.loaders = webpackConfig.module.loaders.map(loader => {
if (/css/.test(loader.test)) {
const [first, ...rest] = loader.loaders;

loader.loader = ExtractTextPlugin.extract(first, rest.join('!'));
delete loader.loaders;
}

return loader;
});

webpackConfig.plugins.push(
new webpack.optimize.UglifyJsPlugin({
output : {
'comments' : false
},
compress : {
'unused' : true,
'dead_code' : true
Expand Down

0 comments on commit a7c3513

Please sign in to comment.