Skip to content

Commit

Permalink
Hot reload styles
Browse files Browse the repository at this point in the history
  • Loading branch information
geowarin committed Apr 30, 2016
1 parent fdde912 commit cbb6a32
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions lib/loaders/dev/css.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = [
{
test: /\.css/,
loaders: ['style', 'css?sourceMap']
}
];
2 changes: 1 addition & 1 deletion lib/loaders/css.js → lib/loaders/prod/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ const ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = [
{
test: /\.css/,
loader: ExtractTextPlugin.extract('css-loader')
loader: ExtractTextPlugin.extract('style', 'css?sourceMap')
}
];
5 changes: 2 additions & 3 deletions lib/webpack/webpack.dev.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const requireDir = require('require-dir');
const path = require('path');
const webpack = require('webpack');

const allLoaders = requireDir('../loaders');
const allLoaders = Object.assign(requireDir('../loaders'), requireDir('../loaders/dev'));
const loaders = Object.keys(allLoaders).reduce((p, k) => p.concat(allLoaders[k]), []);

const env = 'development';
Expand Down Expand Up @@ -35,8 +35,7 @@ module.exports = function devConfig (options) {
new HtmlWebpackPlugin({
title: 'ReactApp',
template: path.join(options.projectDir, 'index.html')
}),
new ExtractTextPlugin('style.css')
})
],
resolve: {
modules: [path.join(options.projectDir, 'src'), 'node_modules'],
Expand Down
4 changes: 2 additions & 2 deletions lib/webpack/webpack.prod.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const requireDir = require('require-dir');
const path = require('path');
const webpack = require('webpack');

const allLoaders = requireDir('../loaders');
const allLoaders = Object.assign(requireDir('../loaders'), requireDir('../loaders/prod'));
const loaders = Object.keys(allLoaders).reduce((p, k) => p.concat(allLoaders[k]), []);

const env = 'production';
Expand Down Expand Up @@ -51,7 +51,7 @@ module.exports = function config (options) {
screw_ie8: true
}
}),
new ExtractTextPlugin('style.css')
new ExtractTextPlugin('style-[hash].css')
],
resolve: {
modules: [path.join(options.projectDir, 'src'), 'node_modules'],
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"redbox-noreact": "^1.0.0",
"require-dir": "^0.3.0",
"resolve": "^1.1.7",
"style-loader": "^0.13.1",
"url-loader": "^0.5.7",
"webpack": "^2.1.0-beta.6",
"webpack-dev-middleware": "^1.6.1",
Expand Down

0 comments on commit cbb6a32

Please sign in to comment.