/
server.js
37 lines (31 loc) · 905 Bytes
/
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
"use strict"
const fs = require("fs")
const path = require("path")
const express = require("express")
const bodyParser = require("body-parser")
const app = express()
const server = require("http").createServer(app)
const ROOT = path.normalize(__dirname + "/..")
const webpack = require("webpack")
const webpackDevMiddleware = require("webpack-dev-middleware")
const webpackConfig = require("./webpack.config")
const compiler = webpack(webpackConfig)
app.use(webpackDevMiddleware(compiler, { publicPath: "/build/" }))
app.use("/build", express.static(__dirname + '/build'))
app.get("/", (req, res) => {
res.send(HTML)
})
server.listen(8080, () => {
console.log("Express server started: http://localhost:8080")
})
const HTML = `
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>众触插件开发</title>
</head>
<body>
<div>众触插件开发</div>
</body>
</html>`