Gitter migration: Setup redirects (rollout pt. 3)
[gitter.git] / server / web / express-static.js
blob66536b904fc0772e2f5c47b7b4fefbd83dbd9b28
1 'use strict';
3 exports.install = function(app) {
4 var express = require('express');
5 var resolveStatic = require('./resolve-static');
6 var favicon = require('serve-favicon');
8 var webpackMiddleware = require('webpack-dev-middleware'); // eslint-disable-line node/no-unpublished-require
9 var webpack = require('webpack'); // eslint-disable-line node/no-unpublished-require
11 app.use(
12 webpackMiddleware(webpack(require('../../public/js/webpack.config')), {
13 logLevel: 'warn',
14 lazy: false,
15 watchOptions: {
16 aggregateTimeout: 400
18 publicPath: '/_s/l/js/',
19 writeToDisk: filePath => {
20 // We use the `webpack-manifest.json` in `hbs-helpers`
21 // to determine which dynamic/dependent chunks to serve
22 return /webpack-manifest\.json$/.test(filePath);
24 stats: {
25 colors: true
30 app.use(
31 '/_s/l/styles',
32 express.static('output/assets/styles', {
33 maxAge: 0
37 var staticServer = express.static(resolveStatic(), {
38 maxAge: 0
39 });
41 app.use('/_s/lt/:cacheBuster', staticServer);
42 app.use('/_s/l', staticServer);
44 app.use(favicon(resolveStatic('favicon.ico')));