mirror of
https://github.com/wassname/generator-react-webpack.git
synced 2026-09-09 11:22:44 +08:00
Merge pull request #29 from ColCh/feature/live-edit
Use HMR api (livereload for app)
This commit is contained in:
@@ -27,6 +27,7 @@ module.exports = function (grunt) {
|
||||
|
||||
'webpack-dev-server': {
|
||||
options: {
|
||||
hot: true,
|
||||
port: 8000,
|
||||
webpack: webpackDevConfig,
|
||||
publicPath: '/assets/',
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
"grunt-open": "~0.2.3",
|
||||
"jshint-loader": "~0.8.0",
|
||||
"grunt-contrib-copy": "~0.5.0",
|
||||
"grunt-contrib-clean": "~0.6.0"
|
||||
"grunt-contrib-clean": "~0.6.0",
|
||||
"react-hot-loader": "^0.4.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
var webpack = require('webpack');
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -17,7 +18,10 @@ module.exports = {
|
||||
cache: true,
|
||||
debug: true,
|
||||
devtool: false,
|
||||
entry: './src/scripts/components/<%= pkg.mainInput %>.jsx',
|
||||
entry: [
|
||||
'webpack/hot/only-dev-server',
|
||||
'./src/scripts/components/<%= pkg.mainInput %>.jsx'
|
||||
],
|
||||
|
||||
stats: {
|
||||
colors: true,
|
||||
@@ -37,7 +41,7 @@ module.exports = {
|
||||
|
||||
loaders: [{
|
||||
test: /\.jsx$/,
|
||||
loader: 'jsx-loader?harmony'
|
||||
loader: 'react-hot!jsx-loader?harmony'
|
||||
}, {
|
||||
test: /\.css$/,
|
||||
loader: 'style-loader!css-loader'
|
||||
@@ -45,6 +49,11 @@ module.exports = {
|
||||
test: /\.(png|jpg)$/,
|
||||
loader: 'url-loader?limit=8192'
|
||||
}]
|
||||
}
|
||||
},
|
||||
|
||||
plugins: [
|
||||
new webpack.HotModuleReplacementPlugin(),
|
||||
new webpack.NoErrorsPlugin()
|
||||
]
|
||||
|
||||
};
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
var path = require('path');
|
||||
var helpers = require('yeoman-generator').test;
|
||||
var assert = require('yeoman-generator').assert;
|
||||
var _ = require('underscore.string');
|
||||
|
||||
describe('react-webpack generator', function() {
|
||||
@@ -93,6 +94,20 @@ describe('react-webpack generator', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('should use HMR webpack API inside of configs', function (done) {
|
||||
react.run({}, function() {
|
||||
assert.fileContent([
|
||||
['package.json', /react-hot-loader/],
|
||||
['Gruntfile.js', /hot:\s*true/],
|
||||
['webpack.config.js', /react-hot/],
|
||||
['webpack.config.js', /webpack\.HotModuleReplacementPlugin/],
|
||||
['webpack.config.js', /webpack\.NoErrorsPlugin/],
|
||||
['webpack.config.js', /webpack\/hot\/only-dev-server/]
|
||||
]);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Subgenerators', function() {
|
||||
|
||||
Reference in New Issue
Block a user