-
Notifications
You must be signed in to change notification settings - Fork 3
/
server.js
46 lines (43 loc) · 1.05 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const browserSync = require("browser-sync");
const webpack = require("webpack");
const webpackDevMiddleware = require("webpack-dev-middleware");
const webpackHotMiddleware = require("webpack-hot-middleware");
const webpackConfig = require("./webpack.dev");
const bundler = webpack(webpackConfig);
const webpackDevMiddlewareInstance = webpackDevMiddleware(bundler, {
publicPath: webpackConfig.output.publicPath,
stats: {
colors: true,
}
});
const server = browserSync({
port: 8080,
ghostMode: false,
socket: {
domain: "localhost:8080",
},
server: {
baseDir: "build",
middleware: [
function (req, res, next) {
res.setHeader("Access-Control-Allow-Origin", "*");
next();
},
webpackDevMiddlewareInstance,
webpackHotMiddleware(bundler),
]
},
files: [
{
/**
* php & pug
*/
match: ["./dev/pug/**/*.pug", "../**/*.php"],
fn: (event, file) => {
webpackDevMiddlewareInstance.waitUntilValid(() => {
server.reload();
});
}
}
]
});