使用webpack-dev-server热更新失败
命令"start": "webpack-dev-server --config webpack.dev.config.js"
webpack/server 版本
`"webpack": "^1.13.1",
"webpack-dev-server": "^1.14.1"`
webpack配置文件
let webpack = require('webpack');
let path = require('path');
let OpenBrowserPlugin = require('open-browser-webpack-plugin');
let autoprefixer=require('autoprefixer');
module.exports = {
devServer: {
hot: true,
inline: true,
progress: true,
port: 7070,
host: '0.0.0.0'
},
entry: {
index: [
'./app/index.js'
],
vendor: [
'react',
'react-dom',
'react-router',
]
},
output: {
path: './dist',
publicPath:'/dist/',
filename:'[name].js',
},
module: {
loaders: [{
test: /\.css$/,
loader: 'style!css!postcss'
}, {
test: /\.js[x]?$/,
exclude: /node_modules/,
loader: 'react-hot!babel'
}, {
test: /\.scss$/,
loader: 'style!css!sass!postcss'
}, {
test: /\.less$/,
loader: 'style!css!less'
},
{test: /\.woff2?$/, loader: 'url?limit=10000&minetype=application/font-woff'},
{test: /\.ttf$/, loader: 'url?limit=10000&minetype=application/octet-stream'},
{test: /\.eot$/, loader: 'file'},
{test: /\.svg$/, loader: 'url?limit=10000&minetype=image/svg+xml'},
{test: /\.(png|jpg|jpeg|gif)$/i, loader: 'url?limit=10000&name=[name].[ext]'},
{test: /\.json$/, loader: 'json'}]
},
resolve: {
extensions: ['', '.js', '.jsx'],
},
postcss: [
autoprefixer({
browsers: ['last 2 versions', 'Firefox ESR', '> 1%', 'ie >= 8']
})
],
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.js'),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': '"development"'
}
})
]
};
index.html
<!DOCTYPE html>
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale =1, user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="format-detection" content="telephone=no">
<meta name="format-detection" content="email=no">
<title>C-IoT</title>
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
<link rel="icon" href="/favicon.ico" type="image/x-icon">
<script src="http://localhost:7070/webpack-dev-server.js"></script>
<script src="https://unpkg.com/mqtt/dist/mqtt.min.js"></script>
</head>
<body >
<div id="root"></div>
<script type="text/javascript" src="/dist/vendor.js"></script>
<script type="text/javascript" src="/dist/index.js"></script>
</body>
</html>
为什么这样配置还是无法热更新,总是报[WDS] Hot Module Replacement enabled.
请问一下该如何修改才能使程序热更新?
打包的代码放在https://github.com/yourenA/we... 如果可以帮我看一下,谢谢
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
热更新要往entry里插入语句的- -不然没用
还有entry要改为数组形式:
你给的文件测试效果: