mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 14:13:37 +08:00
Add hot-middleware
This commit is contained in:
parent
949f6f1a12
commit
4c21a1ac56
39
nico.js
39
nico.js
@ -6,6 +6,7 @@ var inspect = require('util').inspect;
|
|||||||
var Busboy = require('busboy');
|
var Busboy = require('busboy');
|
||||||
var chalk = require('chalk');
|
var chalk = require('chalk');
|
||||||
var webpackMiddleware = require('webpack-dev-middleware');
|
var webpackMiddleware = require('webpack-dev-middleware');
|
||||||
|
var webpackHotMiddleware = require('webpack-hot-middleware');
|
||||||
var webpackConfig = require('./webpack.config');
|
var webpackConfig = require('./webpack.config');
|
||||||
var webpackCompiler = webpack(webpackConfig);
|
var webpackCompiler = webpack(webpackConfig);
|
||||||
var handler;
|
var handler;
|
||||||
@ -89,23 +90,29 @@ exports.middlewares = [
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'webpackDevMiddleware',
|
name: 'webpackDevMiddleware',
|
||||||
filter: /\.(js|css)(\.map)?(\?.*)?$/,
|
filter: /\.(js|css|json)(\.map)?(\?.*)?$/,
|
||||||
handle: function(req, res, next) {
|
handle: function(req, res, next) {
|
||||||
handler = handler || webpackMiddleware(webpackCompiler, {
|
handler = handler || webpackMiddleware(webpackCompiler, {
|
||||||
publicPath: '/dist/',
|
publicPath: webpackConfig.output.publicPath,
|
||||||
lazy: false,
|
lazy: false,
|
||||||
watchOptions: {
|
watchOptions: {
|
||||||
aggregateTimeout: 300,
|
aggregateTimeout: 300,
|
||||||
poll: false
|
poll: false
|
||||||
},
|
},
|
||||||
noInfo: true
|
noInfo: true
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
return handler(req, res, next);
|
return handler(req, res, next);
|
||||||
} catch(e) {}
|
} catch(e) {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'webpackHotMiddleware',
|
||||||
|
filter: /.*/,
|
||||||
|
handle: webpackHotMiddleware(webpackCompiler)
|
||||||
}
|
}
|
||||||
}];
|
];
|
||||||
|
|
||||||
exports.writers = [
|
exports.writers = [
|
||||||
'nico-jsx.PageWriter',
|
'nico-jsx.PageWriter',
|
||||||
|
@ -117,11 +117,12 @@
|
|||||||
"values.js": "^1.0.3",
|
"values.js": "^1.0.3",
|
||||||
"webpack": "^1.10.1",
|
"webpack": "^1.10.1",
|
||||||
"webpack-babel-jest": "^1.0.0",
|
"webpack-babel-jest": "^1.0.0",
|
||||||
"webpack-dev-middleware": "^1.5.1"
|
"webpack-dev-middleware": "^1.5.1",
|
||||||
|
"webpack-hot-middleware": "^2.6.4"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"babel": "babel components index.js --out-dir lib",
|
"babel": "babel components index.js --out-dir lib",
|
||||||
"start": "npm run clean && nico server --watch",
|
"start": "npm run clean && nico server",
|
||||||
"clean": "rm -rf _site dist",
|
"clean": "rm -rf _site dist",
|
||||||
"site": "npm run clean && webpack --config webpack.deploy.config.js && webpack --config webpack.antd.config.js && NODE_ENV=PRODUCTION nico build",
|
"site": "npm run clean && webpack --config webpack.deploy.config.js && webpack --config webpack.antd.config.js && NODE_ENV=PRODUCTION nico build",
|
||||||
"deploy": "rm -rf node_modules && node scripts/install.js && npm run just-deploy",
|
"deploy": "rm -rf node_modules && node scripts/install.js && npm run just-deploy",
|
||||||
|
@ -4,7 +4,7 @@ var path = require('path');
|
|||||||
var pkg = require('./package');
|
var pkg = require('./package');
|
||||||
|
|
||||||
var entry = {};
|
var entry = {};
|
||||||
entry['demo'] = './scripts/demo.js';
|
entry['demo'] = ['./scripts/demo.js', 'webpack-hot-middleware/client'];
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
entry: entry,
|
entry: entry,
|
||||||
@ -20,6 +20,7 @@ module.exports = {
|
|||||||
|
|
||||||
output: {
|
output: {
|
||||||
path: path.join(process.cwd(), 'dist'),
|
path: path.join(process.cwd(), 'dist'),
|
||||||
|
publicPath: '/dist/',
|
||||||
filename: '[name].js'
|
filename: '[name].js'
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -57,7 +58,10 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
plugins: [
|
plugins: [
|
||||||
new ExtractTextPlugin('[name].css')
|
new ExtractTextPlugin('[name].css'),
|
||||||
|
new webpack.optimize.OccurenceOrderPlugin(),
|
||||||
|
new webpack.HotModuleReplacementPlugin(),
|
||||||
|
new webpack.NoErrorsPlugin()
|
||||||
],
|
],
|
||||||
|
|
||||||
devtool: 'source-map'
|
devtool: 'source-map'
|
||||||
|
Loading…
Reference in New Issue
Block a user