-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
25 lines (22 loc) · 882 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
const express = require('express');
const app = express();
const chalk = require('chalk');
const env = process.env.NODE_ENV || 'development';
const port = process.env.PORT || 3000;
if (env === 'development') {
const webpack = require('webpack');
const webpackDevMiddleware = require('webpack-dev-middleware');
const config = require('./webpack.config.js');
const compiler = webpack(config);
app.use(webpackDevMiddleware(compiler, {
publicPath: config.output.publicPath,
}));
}
app.use(express.static('client'));
app.listen(port, () => {
const {bgRed, bgYellow, bgGreen, bgCyan, white} = chalk;
const phaser = `${bgRed(' ')}${bgYellow(' ')}${bgGreen(' ')}${bgCyan(' ')}`;
const name = process.env.npm_package_name;
const version = process.env.npm_package_version;
console.log(white.bgBlack(`${phaser} ${name} ${version} http://localhost:${port} `));
});