node server.js
时会加载我的项目,但文件没有被热重新加载。
// webpack stuff
var webpack = require("webpack");
var webpackDevMiddleware = require("webpack-dev-middleware");
var webpackHotMiddleware = require("webpack-hot-middleware");
var config = require("./webpack.config");
var compiler = webpack(config);
// email template
var emailTemplate = require("./emailTemplate");
// express
var express = require("express");
var app = express();
var crypto = require("crypto");
var bodyParser = require("body-parser");
var cookieParser = require("cookie-parser");
var port = 8000;
app.use(webpackDevMiddleware(compiler, { noInfo: true, publicPath: config.output.publicPath }));
app.use(webpackHotMiddleware(compiler));
app.use(express.static(__dirname + "/src"));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(cookieParser());
....... shorten for security
var webpack = require('webpack');
module.exports = {
entry: [
'webpack/hot/dev-server',
'webpack-hot-middleware/client',
'./src/index.js'
],
output: {
path: __dirname + '/src/build',
filename: 'bundle.js',
public: '/',
publicPath: 'http://localhost:8000/public/'
},
module: {
loaders: [
{
test: /\.jsx?$/,
loaders: ['babel'],
exclude: /node_modules/,
include: __dirname + '/src'
},
{
test: /\.json$/,
loader: 'json-loader'
},
{
test: /\.css$/,
loader: 'style-loader!css-loader!postcss-loader'
},
{
test: /\.(png|jpg|jpeg|gif|woff)$/,
loader: 'url-loader?limit=8192'
}
]
},
jest: {
moduleFileExtensions: ["js", "jsx"]
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
]
};
如果有其他文件可供查看,请与我们联系。