|
7 년 전 | |
---|---|---|
.. | ||
.editorconfig | 7 년 전 | |
.eslintrc | 7 년 전 | |
.npmignore | 7 년 전 | |
LICENSE | 7 년 전 | |
README.md | 7 년 전 | |
circle.yml | 7 년 전 | |
index.js | 7 년 전 | |
package.json | 7 년 전 |
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.
Install the plugin with npm:
$ npm i inline-manifest-webpack-plugin -D
This plugin need to work with HtmlWebpackPlugin v2.10.0 and above:
Step1: split out the runtime code
// for explicit vendor chunk config
[
new webpack.optimize.CommonsChunkPlugin({
names: ['vendor', 'manifest']
})
]
// or specify which chunk to split manually
[
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
chunks: ['...']
})
]
Step2: config HtmlWebpackPlugin:
[
new HtmlWebpackPlugin({
template: './index.ejs'
})
]
Step3: config InlineManifestWebpackPlugin
webpackManifest
, result in htmlWebpackPlugin.files[name]
, you can specify any other name except manifest
, beacuse the name manifest
haved been used by HtmlWebpackPlugin for H5 app cache manifest.
javascript
[
new InlineManifestWebpackPlugin({
name: 'webpackManifest'
})
]
<!-- index.ejs -->
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>App</title>
</head>
<body>
<%=htmlWebpackPlugin.files.webpackManifest%>
</body>
</html>
Done!