猿问

webpack 怎么直接实时编译输出文件?

webpack 怎么直接实时编译输出文件


ibeautiful
浏览 778回答 1
1回答

慕的地6264312

新建一个server服务用他来启动监听webpack.config.js用node server.js启动服务var webpack = require('webpack');var webpackDevMiddleware = require("webpack-dev-middleware");var webpackDevServer = require('webpack-dev-server');var config = require("./webpack.config.js");config.entry.index.unshift('webpack/hot/dev-server');config.entry.index.unshift('webpack-dev-server/client?http://localhost:8080');var compiler = webpack(config);var server = new webpackDevServer(compiler, {historyApiFallback: true,hot: true,inline: true,stats: 'errors-only',host: "localhost",port: "8080",});server.listen(8080);
随时随地看视频慕课网APP
我要回答