我在一个非常简单的设置中使用webpack-dev-server
。 我发现即使服务器在index.js
文件更改时自动触发浏览器重新加载,而不是在index.html
更改时会触发重新加载。我怎样才能做到这一点?当index.html更改时浏览器自动重新加载
这里是我的设置:
的package.json
{
"name": "html-reload",
"version": "1.0.0",
"description": "",
"main": "src/index.js",
"scripts": {
"build": "node_modules/webpack/bin/webpack.js",
"start": "webpack-dev-server --host 0.0.0.0 --port 8383 --content-base dist"
},
"author": "",
"license": "ISC",
"devDependencies": {
"webpack": "^1.12.14",
"webpack-dev-server": "^1.14.1"
}
}
webpack.config.js
module.exports = {
entry: './src/index.js',
output: {
path: 'dist',
filename: 'bundle.js'
}
};
我启动webpack-dev-server
有:npm run start
和我点我的浏览器到:
http://localhost:8383/webpack-dev-server/index.html
我在src/index.js
中所做的每个更改都会在浏览器中自动刷新,但在dist/index.html
中所做的更改不会自动刷新。