webpack-dev-server 如何保存本地文件
http://webpack.github.io/docs/webpack-dev-server.html
里说
This modified bundle is served from memory at the relative path specified in publicPath (see API). It will not be written to your configured output directory.
这样 webpack-dev-server 每次build后本地最终的文件没有修改,还要手动执行webpack 一次
有什么方案 让 webpack-dev-server build后,本地文件也修改?
我是这样配置的
var myConfig = {
entry: "./js/index",
output: {
path: "./dist/js",
publicPath: 'dist/js/',
filename: "index.min.js",
chunkFilename: "[id].chunk.js",
libraryTarget: "umd"
}
}
gulp.task('script', function() {
webpack(myConfig);
})
gulp.task("serve", function() {
var config = Object.assign(myConfig);
config.debug = true;
config.devtool = "source-map";
config.output.path = '/'; //gulp 里出现报错,,设置path
new WebpackDevServer(webpack(config), {
publicPath: '/' + config.output.publicPath,
stats: {
colors: true
},
}).listen(3001, "localhost", function(err) {
if (err) throw new gutil.PluginError("webpack-dev-server", err);
});
});
测试在Serve task的回调或者WebpackDevServer listen的回调里 运行
gulp.start('script')
都会报错
领主灰烬使者
9 years, 7 months ago