JSPM

webpack-dev-server-fallback

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q28616F
  • License ISC

Use a static directory as a fallback for requests to `webpack-dev-server` when the build isn't ready.

Package Exports

  • webpack-dev-server-fallback

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (webpack-dev-server-fallback) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

webpack-dev-server-fallback

Use a static directory as a fallback for requests to webpack-dev-server when the build isn't ready.

Useful in conjunction with HtmlWebpackPlugin to avoid blank screens and timeouts.

Don't use webpack-dev-server in production. This is for in-between cases.

Install

npm install webpack-dev-server-fallback --save(-dev)

Use

In such as webpack.config.js:

const webpackDevServerFallback = require('webpack-dev-server-fallback');

module.exports = {
  devServer: {
    before: webpackDevServerFallback()
  }
};

webpackDevServerFallback takes an options object with two properties:

  • wait: milliseconds to wait for build to be ready before serving fallback (default: 300)
  • directory: source for fallback files (default: "fallback", is passed to express.static)
module.exports = {
  devServer: {
    before: webpackDevServerFallback({wait: 1000, directory: 'dist'})
  }
};

If you have other business to conduct with devServer.before:

module.exports = {
 devServer: {
   before(app, server) {
     // ...code, code, code
     webpackDevServerFallback()(app, server);
   }
 }
};