Allow starting in prod env

This commit is contained in:
Markus Olsson 2017-04-17 22:23:45 +02:00
parent 8db3c11c2d
commit 06cfe88c39
2 changed files with 15 additions and 2 deletions

View file

@ -12,6 +12,7 @@
"test:review": "node script/test-review",
"postinstall": "cd app && npm install && cd .. && git submodule update --recursive --init && npm run compile:tslint",
"start": "cross-env NODE_ENV=development node script/start",
"start:prod": "cross-env NODE_ENV=production node script/start",
"debug": "cross-env NODE_ENV=development node script/debug",
"compile:dev": "cross-env NODE_ENV=development webpack --config app/webpack.development.js",
"compile:prod": "cross-env NODE_ENV=production webpack --config app/webpack.production.js",

View file

@ -2,17 +2,29 @@
'use strict'
const run = require('./run')
if (process.env.NODE_ENV === 'production') {
const runningApp = run()
if (!runningApp) {
console.error("Couldn't launch the app. You probably need to build it first. Run `npm run build:dev`.")
process.exit(1)
}
return
}
const express = require('express')
const webpack = require('webpack')
const config = require('../app/webpack.development')
const run = require('./run')
const server = express()
const compiler = webpack(config)
const port = process.env.PORT || 3000
server.use(require('webpack-dev-middleware')(compiler, {
publicPath: config.output.publicPath,
publicPath: config[2].output.publicPath,
noInfo: true
}))