Skip to content
This repository has been archived by the owner on Jun 8, 2022. It is now read-only.

Commit

Permalink
Option to remove chunk manifest asset
Browse files Browse the repository at this point in the history
  • Loading branch information
jouni-kantola committed Apr 8, 2017
1 parent b05ef5f commit 7fedeb1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = {
template: './index-template.ejs'
}),
// InlineChunkManifestHtmlWebpackPlugin defaults to:
// { filename: 'manifest.json', manifestVariable: 'webpackManifest', chunkManifestVariable: 'webpackChunkManifest' }
// { filename: 'manifest.json', manifestVariable: 'webpackManifest', chunkManifestVariable: 'webpackChunkManifest', dropAsset: false }
// match { filename, manifestVariable } with ChunkManifestPlugin
new InlineChunkManifestHtmlWebpackPlugin(),
new InlineManifestPlugin()
Expand All @@ -43,6 +43,7 @@ const inlineChunkManifestConfig = {
filename: 'manifest.json', // manifest.json is default; matches chunk-manifest-webpack-plugin
manifestVariable: 'webpackManifest', // webpackManifest is default; matches chunk-manifest-webpack-plugin
chunkManifestVariable: 'webpackChunkManifest' // webpackChunkManifest is default; use in html-webpack-plugin template
dropAsset: true // false is default; use to skip output of the chunk manifest asset (removes manifest.json)
};

new InlineChunkManifestHtmlWebpackPlugin(inlineChunkManifestConfig)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "inline-chunk-manifest-html-webpack-plugin",
"version": "0.2.0",
"version": "0.2.1",
"description": "Plugin to inline webpack chunk manifest. Default inlines in head tag. Use together with html-webpack-plugin, chunk-manifest-webpack-plugin and inline-manifest-webpack-plugin.",
"main": "./src/index.js",
"scripts": {
Expand Down
6 changes: 6 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ function InlineChunkManifestHtmlWebpackPlugin(options) {
this.manifestFilename = options.filename || "manifest.json";
this.manifestVariable = options.manifestVariable || "webpackManifest";
this.chunkManifestVariable = options.chunkManifestVariable || "webpackChunkManifest";
this.dropAsset = options.dropAsset || false;
}

InlineChunkManifestHtmlWebpackPlugin.prototype.apply = function (compiler) {
const manifestFilename = this.manifestFilename;
const manifestVariable = this.manifestVariable;
const chunkManifestVariable = this.chunkManifestVariable;
const dropAsset = this.dropAsset;

compiler.plugin("compilation", function (compilation) {
compilation.plugin('html-webpack-plugin-alter-asset-tags', function (htmlPluginData, callback) {
Expand All @@ -25,6 +27,10 @@ InlineChunkManifestHtmlWebpackPlugin.prototype.apply = function (compiler) {
};

htmlPluginData.head.unshift(newTag);

if(dropAsset) {
delete compilation.assets[manifestFilename];
}
}

callback(null, htmlPluginData);
Expand Down

0 comments on commit 7fedeb1

Please sign in to comment.