我之前有这个配置
module: {
loaders: [
{
loaders:['react-hot','babel-loader'],
query: {presets: ["react", "es2015", "stage-0"]},
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/
}
]
},
devtool: 'cheap-module-eval-source-map'
};
添加hot-loader,我不得不将'loader'更改为'loaders',但后来遇到了webpack无法读取查询的问题。要修复,我试过这个但是没有用
var webpack = require('webpack');
module.exports = {
entry:
[
'webpack-dev-server/client?http://0.0.0.0:3000', // WebpackDevServer host and port
'webpack/hot/only-dev-server', // "only" prevents reload on syntax errors
'./scripts/index',
"script!jquery/dist/jquery.min.js",
"script!foundation-sites/dist/foundation.min.js",
"./app/app.jsx"
],
externals: {
jquery: 'jQuery'
},
plugins: [
new webpack.ProvidePlugin({
'$':'jquery',
'jQuery':'jquery'
}),
new webpack.HotModuleReplacementPlugin()
],
output: {path: __dirname, filename: "./public/bundle.js"},
resolve: {
root: __dirname,
alias: {
Main: "app/components/main.jsx",
Nav: "app/components/nav.jsx",
applicationStyles: 'app/styles/app.scss'
},
extensions: ["", ".js", ".jsx"]
},
module: {
loaders: [
{
loaders:['react-hot','babel-loader','babel?presets[]=es2015,presets[]=stage-0,presets[]=react'],
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/
}
]
},
devtool: 'cheap-module-eval-source-map'
};