-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
27 lines (23 loc) · 1003 Bytes
/
app.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
const webpack = require("webpack");
const middleware = require("webpack-dev-middleware");
const webpackConfig = require("./webpack.config.js");
const compiler = webpack(webpackConfig);
const express = require("express");
// const path = require("path");
const port = 9000;
const app = express();
app.get("/", (req, res, next) => {
next(); // response를 보내지 않고, 다음에 해당하는게 있다면 그 다음으로 넘어가는 기능, 여기서는 middleware가 되는 것
});
// 요청을 보낼 때 여기에 들어오고 나가는지 확인하려면 디버깅을 해야하는데, 이게 없으면 콘솔 넣을 구간없이 넘어가버리니까 확인이 어려움
// 없어도 돌아가긴 하는데, 디버깅을 위해 좋음
app.use(
middleware(compiler, {
publicPath: webpackConfig.output.publicPath,
stats: { colors: true },
})
);
app.use(express.static(__dirname));
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`);
});