Javascript 网页包开发服务器未重新加载.html
试着进入网页。使用官方文件。index.js会重新加载,但index.html不会。 用于生成的命令:webpack dev server--模式开发--打开 vs代码中的项目 wp配置:Javascript 网页包开发服务器未重新加载.html,javascript,web,webpack,Javascript,Web,Webpack,试着进入网页。使用官方文件。index.js会重新加载,但index.html不会。 用于生成的命令:webpack dev server--模式开发--打开 vs代码中的项目 wp配置: const path = require('path'); module.exports = { entry: './src/index.js', output: { filename: 'index.js', path: path.resolve(__dirname, './di
const path = require('path');
module.exports = {
entry: './src/index.js',
output: {
filename: 'index.js',
path: path.resolve(__dirname, './dist'),
},
devServer: {
}
};
package.json脚本:
"scripts": {
"build": "webpack --mode production",
"dev": "webpack-dev-server --mode development --open"
},
网页版本:
"devDependencies": {
"webpack": "^4.10.2",
"webpack-cli": "^2.1.4",
"webpack-dev-server": "^3.1.4"
}
*不要问HtmlWebpackPlugin,我认为没有这个黑客应该可以工作。我使用HtmlWebpackPlugin,效果很好
plugins: [
new HtmlWebpackPlugin({
template: './index.html'
})
]
调用
npm run dev