prismarine-web-client/server.js
dada513 4d4b32e8de
Added docker support, made config dynamic (#108)
* Made config.json dynamic

* added docker support

* Fixed dockerfile npm install error

* fixed line ends

* Revert "Made config.json dynamic"

This reverts commit 5cb413b9aa.

* config.json is now loaded dynamically

* Made dynamic config work on github page

* config is now dynamically copied

* removed sync-request dependency

Co-authored-by: d513 <ogoniasty513@gmail.com>
2021-03-21 17:14:14 +01:00

34 lines
1,013 B
JavaScript

#!/usr/bin/env node
const express = require('express')
const netApi = require('net-browserify')
const compression = require('compression')
const path = require('path')
// Create our app
const app = express()
app.get('/config.json', (_, res) => res.sendFile(path.join(__dirname, 'config.json')))
app.use(compression())
app.use(netApi({ allowOrigin: '*' }))
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')))
}
// Start the server
const server = app.listen(process.argv[2] === undefined ? 8080 : process.argv[2], function () {
console.log('Server listening on port ' + server.address().port)
})