@randy-ang/webpack-retry-chunk-load-plugin

1.4.1 • Public • Published

webpack-retry-chunk-load-plugin

Build Status codecov npm version GitHub issues GitHub stars GitHub license

A webpack plugin to retry loading of async chunks that failed to load

screenshot 2018-10-24 at 21 47 39

Installing

yarn add @randy-ang/webpack-retry-chunk-load-plugin

Usage

// webpack.config.js
const { RetryChunkLoadPlugin } = require('webpack-retry-chunk-load-plugin');

plugins: [
  new RetryChunkLoadPlugin({
    // optional stringified function to get the cache busting query string appended to the script src
    // if not set will default to appending the string `?retry-attempt=<retries-done>`
    cacheBust: `function() {
      return Date.now();
    }`,
    // optional value to set the maximum number of retries to load the chunk. Default is 1
    maxRetries: 5,
    // optional list of chunks to which retry script should be injected
    // if not set will add retry script to all chunks that have webpack script loading
    chunks: ['chunkName'],
    // optional code to be executed in the browser context if after all retries chunk is not loaded.
    // if not set - nothing will happen and error will be returned to the chunk loader.
    lastResortScript: "window.location.href='/500.html';",
    // timeout (in milliseconds) before retrying to load chunk, defaults to 0
    delay: 1000
  })
];

angular cli

To use this with the angular CLI you can use the fantastic angular-builders project to extend the built in webpack config

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i @randy-ang/webpack-retry-chunk-load-plugin

Weekly Downloads

2

Version

1.4.1

License

MIT

Unpacked Size

9.97 kB

Total Files

4

Last publish

Collaborators

  • randy-ang