HTML Webpack Plugin
all-chunks-loaded-webpack-plugin forProvide callback executed after all chunks loaded.
Install via npm
npm install --save-dev all-chunks-loaded-webpack-plugin
- Latest release: https://github.com/devpreview/all-chunks-loaded-webpack-plugin/releases
- NPM: https://www.npmjs.com/package/all-chunks-loaded-webpack-plugin
Usage
The plugin will update all your webpack
chunks with attribute onload
contains onload callback. Just add the plugin to your webpack config as follows:
webpack.config.js
const HtmlWebpackPlugin = const AllChunksLoadedWebpackPlugin = ; moduleexports = ... plugins: callback: "alert('All chunks loaded!');" ...
This will generate a file dist/index.html
containing the following:
Webpack App
Options
You can pass a hash of configuration options to all-chunks-loaded-webpack-plugin
. Allowed values are as follows:
Name | Type | Default | Description |
---|---|---|---|
callback |
{String} |
undefined |
Your callback called after all chunks loaded |
errorCallback |
{String} |
undefined |
Your callback called if some chunk has loading error |
chunks |
{String[]} |
undefined |
Allows you to callback called only some chunks loaded |
excludeChunks |
{String[]} |
undefined |
Allows you to skip callback called some chunks loaded |
Here's an example webpack
config illustrating how to use these options:
webpack.config.js
moduleexports = ... plugins: callback: '/* Put your callback here */' ...
Credit
- HTML Webpack Plugin - Simplifies creation of HTML files to serve your webpack bundles.
See also
- async-stylesheet-webpack-plugin - Loading stylesheets asynchronously;
- Script Extension for HTML Webpack Plugin - Enhances html-webpack-plugin functionality with different deployment options for your scripts including 'async', 'preload', 'prefetch', 'defer', 'module', custom attributes, and inlining;
- preload-webpack-plugin - A webpack plugin for injecting into HtmlWebpackPlugin pages, with async chunk support.
Need a feature?
Welcome to issues!