webpack 怎么直接实时编译输出文件
1个回答
展开全部
新建一圆基晌个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);
用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);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询