const fs = require('fs-extra');
const express = require('express');
const pathModule = require('path');

const getDistDir = (src, distDir) => {
  const srcRelative = pathModule.relative(process.cwd(), src);
  return pathModule.resolve(pathModule.join(distDir, srcRelative));
};

class StaticApp {
  constructor({ path, src }) {
    this._path = path;
    this._src = src;
  }

  prepareMiddleware({ dev, distDir }) {
    const app = express();
    const folderToServe = dev ? this._src : getDistDir(this._src, distDir);
    app.use(this._path, express.static(folderToServe));
    return app;
  }

  build({ distDir }) {
    const source = pathModule.resolve(this._src);
    const destination = getDistDir(this._src, distDir);
    return fs.copy(source, destination);
  }
}

module.exports = {
  StaticApp,
};

@@ -57,24 +57,82 @@
 'express');%0A
+const fallback = require('express-history-api-fallback');%0A
 const pathMo
@@ -155,16 +155,16 @@
 path');%0A
-
 %0Aconst g
@@ -373,16 +373,26 @@
 ath, src
+, fallback
  %7D) %7B%0A  
@@ -433,16 +433,47 @@
  = src;%0A
+    this._fallback = fallback;%0A
   %7D%0A%0A  p
@@ -608,24 +608,24 @@
 , distDir);%0A
-
     app.use(
@@ -668,16 +668,114 @@
 erve));%0A
+    if (this._fallback) %7B%0A      app.use(fallback(this._fallback, %7B root: folderToServe %7D));%0A    %7D%0A
     retu

Add express-history-api-fallback to static app