-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.ts
43 lines (31 loc) · 1017 Bytes
/
app.ts
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
38
39
40
41
42
43
import * as compression from 'compression';
import * as express from 'express';
import * as favicon from 'serve-favicon';
import * as path from 'path';
import * as webpack from 'webpack';
const vash = require('vash');
const webpackConfig = require('./webpack.config');
const app = express();
if (process.env.NODE_ENV !== 'production') {
const compiler = webpack(webpackConfig);
console.log('Using dev-middleware');
app.use(require('webpack-dev-middleware')(compiler, {
noInfo: true,
publicPath: webpackConfig.output.publicPath,
hot: true,
stats: {
colors: true,
},
watchOptions: {
poll: 300, // docker support
},
}));
app.use(require('webpack-hot-middleware')(compiler));
}
app.use(compression());
app.use(favicon(path.join(__dirname, 'favicon.ico')));
app.use('/static', express.static(path.join(__dirname, 'dist')));
app.set('view engine', 'cshtml');
app.set('views', path.join(__dirname, 'views'));
app.engine('cshtml', vash.renderFile);
export = app;