Webpack Inline Manifest Plugin
This is a webpack plugin that inline your manifest.js with a script tag to save http request. Cause webpack's runtime always change between every build, it's better to split the runtime code out for long-term caching.
Installation
Install the plugin with npm:
$ npm i webpack-inline-manifest-plugin -D
Basic Usage
This plugin need to work with HtmlWebpackPlugin v2.10.0 and above:
Step1: split out the runtime code
// for explicit vendor chunk config names: 'vendor' 'manifest' // or specify which chunk to split manually name: 'manifest' chunks: '...'
Step2: config HtmlWebpackPlugin:
template: './index.ejs'
Step3: config WebpackInlineManifestPlugin
- name: default value is
webpackManifest
, result inhtmlWebpackPlugin.files[name]
, you can specify any other name exceptmanifest
, beacuse the namemanifest
haved been used by HtmlWebpackPlugin for H5 app cache manifest.
Call:
const WebpackInlineManifestPlugin = ;
Config:
name: 'webpackManifest'
Finally in HTML:
<!-- index.ejs --> App <%=htmlWebpackPlugin.files.webpackManifest%>
Done!