-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
executable file
·37 lines (28 loc) · 1.04 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
const express = require('express')
const fs = require('fs')
const webpack = require('webpack')
const webpackDevMiddleware = require('webpack-dev-middleware')
const PORT = 4000
const app = express()
// list all proto folders
const allProtos = fs.readdirSync('./src').filter(
item => item.indexOf('proto-') > -1
)
console.log('allprotos', allProtos)
// enable webpack for the last prototype to speed up the building process
// as we dont need to deal with old prototypes
const latestProtos = allProtos.slice(-2)
console.log('lastestProtos', latestProtos)
// create a list with all proto-* webpack config files
const compiler = webpack(latestProtos.map(
ID => require('./internals/webpack.base')({ ID })
))
app.use(webpackDevMiddleware(compiler, { publicPath: '/', logLevel: 'warn' }))
// add static folder if we have common assets
app.use(express.static('./docs'))
const router = express.Router()
/* GET home page. */
router.get('/', (req, res, next) =>
res.sendFile('./docs/index.html')
)
app.listen(PORT, () => console.log(`Listening on port ${PORT}!`))