Leverages on favicons to automatically generate your progressive web app for you.
Install the plugin with npm:
$ npm install --save-dev webapp-webpack-plugin
Add the plugin to your webpack config as follows:
const WebappWebpackPlugin =...plugins:'/path/to/logo.png' // svg works too!
The default configuration will automatically generate webapp manifest files along with
44 different icon formats
as appropriate for iOS devices, Android devices, Windows Phone and various desktop browsers out of your single
Tip: You might want to fine tune what vendors to support.
A Note on Path Resolution
Under the hood, Webpack resolves the path to logo according to the following rules:
/path/to/logois absolute, there is nothing to resolve and the path specified is used as is.
./path/to/logois relative, it's resolved with respect to Webpack's
context, which defaults to
path/to/logois neither explicitly relative nor absolute, Webpack attempts to resolve it according to
resolve.modules, which defaults to
In combination with html-webpack-plugin it will also inject the necessary html for you:
html-webpack-pluginmust come before
webapp-webpack-pluginin the plugins array.
plugins:// Your source logo (required)logo: '/path/to/logo.png'// Enable caching and optionally specify the path to store cached data// Note: disabling caching may increase build times considerablycache: true// Override the publicPath option usually read from webpack configurationpublicPath: '/static'// The directory to output the assets relative to the webpack output dir.// Relative string paths are allowed here ie '../public/static'. If this// option is not set, `prefix` is used.outputPath: '/public/static'// Prefix path for generated assetsprefix: 'assets/'// Inject html links/metadata (requires html-webpack-plugin).// This option accepts arguments of different types:// * boolean// `false`: disables injection// `true`: enables injection if that is not disabled in html-webpack-plugin// * string// `'force'`: enables injection even if that is disabled in html-webpack-plugin// * function// any predicate that takes an instance of html-webpack-plugin and returns either// `true` or `false` to control the injection of html metadata for the html files// generated by this instance.inject: true// Favicons configuration options (see below)favicons:...
To fine tune what icons/metadata is generated, refer to favicons' documentation.
The options specified under
favicons: are handed over as is to favicons,
except that if
developerURL are left
undefined, they will be automatically inferred
author.url as defined in the nearest
package.json if available.
To disable automatically retrieving metadata from
package.json, simply set
null the properties you want to omit.
const WebappWebpackPlugin =...plugins:logo: '/path/to/logo.png' // svg works too!favicons:appName: 'my-app'appDescription: 'My awesome App'developerName: 'Me'developerURL: null // prevent retrieving from the nearest package.jsonbackground: '#ddd'theme_color: '#333'icons:coast: falseyandex: false
Handling Multiple HTML Files
const WebappWebpackPlugin =const HtmlWebpackPlugin =const basename =...plugins:template: 'a.html.tmpl'filename: 'a.html'template: 'b.html.tmpl'filename: 'b.html'logo: 'logo.svg'=== 'a.html'
To allow other plugins to intercept and customise assets before they are emitted, the following hooks may be tapped
A Webpack loader rule is also provided to make the generated HTML tags available to your JS app.
const plugin = logo: '/path/to/logo.png' ;...plugins:pluginmodule:rules:plugin
// now inside Webpack bundle// you can require logo path// and get an array of strings with html tagsconst favicons = ;
logomust be an absolute path for
Please keep in mind that every change and new feature should be covered by tests.
This project is licensed under MIT.