2021-02-27 17:28:08 -05:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
2021-02-27 17:12:11 -05:00
|
|
|
const express = require('express')
|
|
|
|
const netApi = require('net-browserify')
|
|
|
|
const compression = require('compression')
|
2021-02-27 17:35:59 -05:00
|
|
|
const path = require('path')
|
2021-02-27 17:12:11 -05:00
|
|
|
|
|
|
|
// Create our app
|
|
|
|
const app = express()
|
|
|
|
|
|
|
|
app.use(compression())
|
2021-03-03 19:39:21 -05:00
|
|
|
app.use(netApi({ allowOrigin: '*' }))
|
2021-03-05 19:29:28 -05:00
|
|
|
if (process.argv[3] === 'dev') {
|
|
|
|
// https://webpack.js.org/guides/development/#using-webpack-dev-middleware
|
|
|
|
const webpackDevMiddleware = require('webpack-dev-middleware')
|
|
|
|
const config = require('./webpack.dev.js')
|
|
|
|
const webpack = require('webpack')
|
|
|
|
const compiler = webpack(config)
|
|
|
|
|
|
|
|
app.use(
|
|
|
|
webpackDevMiddleware(compiler, {
|
|
|
|
publicPath: config.output.publicPath
|
|
|
|
})
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
app.use(express.static(path.join(__dirname, './public')))
|
|
|
|
}
|
2021-02-27 17:12:11 -05:00
|
|
|
|
|
|
|
// Start the server
|
2021-03-03 03:59:36 -05:00
|
|
|
const server = app.listen(process.argv[2] === undefined ? 8080 : process.argv[2], function () {
|
2021-02-27 17:12:11 -05:00
|
|
|
console.log('Server listening on port ' + server.address().port)
|
|
|
|
})
|