// // 方法二实现热重载
// // 引入chokidar
// const chokidar = require('chokidar');
// const webpack = require('webpack');
// const webpackDevMiddleware = require('webpack-dev-middleware');
// const webpackHotMiddleware = require('webpack-hot-middleware');
// const webpackConfig = require('./webpack.config');
// const path = require('path');
// const express = require('express')
// const app = express();
// const compiler = webpack(webpackConfig);
// const devMiddleWare = webpackDevMiddleware(compiler, {
// publicPath: webpackConfig.output.publicPath,
// // noInfo: true,
// // hot: true,
// // 这里强制将html文件写入(需要为编译后的html文件设置模板引擎)
// writeToDisk: (filename) => {
// return /\.html$/.test(filename)
// },
// stats: {
// colors: true
// }
// })
// const hotMiddleware = webpackHotMiddleware(compiler)
// app.use(devMiddleWare)
// app.use(hotMiddleware);
// getProxy()
// // 以下开始监听目标文件/dist/index.html的变动,watcher.on('change',...)时候触发更新
// app.active = () => {
// const watcher = chokidar.watch([
// path.resolve(__dirname, '/dist/index.html'),
// ]);
// watcher.on('ready', function () {
// console.log('Initial scan complete. Ready for changes');
// });
// watcher.on('change', function (path) {
// console.log('File [' + path + '] changed !');
// // 重点!! reload the client on file changes
// hotMiddleware.publish({ action: 'reload' });
// });
// }
// app.active()
// app.listen(3002, function () {
// console.log("example app listening on port 3002\n")
// })