How to use the webpack-dev-middleware/lib/GetFilenameFromUrl function in webpack-dev-middleware

To help you get started, we’ve selected a few webpack-dev-middleware examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github reworkjs / reworkjs / src / framework / server / setup-http-server / setup-dev.js View on Github external
expressApp.use((req, res) => {

    const fileName = getFilenameFromUrl(httpStaticPath, fsClientOutputPath, req.url);

    // pre-renderer root route rather than giving index.html.
    if (!fileName || fileName === fsClientOutputPath) {
      return renderRoute(req, res, preRenderReactApp);
    }

    isReadable(fileName, readable => {
      if (readable) {
        return serveStaticFile(res, fileName);
      }

      return renderRoute(req, res, preRenderReactApp);
    });
  });
}
github reworkjs / reworkjs / src / framework / server / middlewares / serve-react-middleare / DevMiddleware.js View on Github external
this.app.use((req, res, next) => {
        const fileName = getFilenameFromUrl(config.publicPath, compiler.outputPath, req.url);

        if (!fileName) {
          return next();
        }

        if (fileName === compiler.outputPath) {
          return renderRoute(req, res, next);
        }

        next();
      });
    }

webpack-dev-middleware

A development middleware for webpack

MIT
Latest version published 2 months ago

Package Health Score

97 / 100
Full package analysis