在我的项目中,我使用webpack-dev-server热重新加载我的应用程序,我也使用html-webpack-plugin将javascript文件自动插入到模板文件中,但是当我使用webpack-dev-server时,注入包后的模板文件不会被写入磁盘,而是在内存中。
我需要html-webpack-plugin首先将包文件插入模板html,然后将模板写入dist目录。那么如何配置它呢?
我使用webpack-dev-middleware
app.use(middleware(compiler,{
publicPath: config.output.publicPath,
hot: true,
writeToDisk: true
}));我以为writeToDisk能做到这一点,但它做不到。
发布于 2018-03-27 14:19:14
webpack-dev-server不将捆绑的文件写入磁盘,它只从内存中读取文件。
要将捆绑的文件写入磁盘,您必须在webpack --watch的npm scripts of package.json中手动使用package.json,这样您的start script看起来就像下面这样
"scripts": {
"start": "webpack --watch && webpack-dev-server --progress --colors",
}https://stackoverflow.com/questions/49515012
复制相似问题