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

Commit 593dfff

Browse files
committed
Explicit choice to ignore extract manifest
1 parent 4e8c442 commit 593dfff

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ const inlineChunkManifestConfig = {
4242
manifestVariable: 'webpackManifest', // webpackManifest is default
4343
chunkManifestVariable: 'webpackChunkManifest', // webpackChunkManifest is default; use in html-webpack-plugin template
4444
dropAsset: true, // false is default; use to skip output of the chunk manifest asset (removes manifest.json)
45-
manifestPlugins: [/* override default chunk manifest plugin(s) */]
45+
manifestPlugins: [/* override default chunk manifest plugin(s) */],
46+
extractManifest: false // true is default. When set to false, manifestPlugins (incl default) is not applied
4647
};
4748

4849
new InlineChunkManifestHtmlWebpackPlugin(inlineChunkManifestConfig)

src/index.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ class InlineChunkManifestHtmlWebpackPlugin {
1212
options.chunkManifestVariable || "webpackChunkManifest";
1313
this.dropAsset = options.dropAsset || false;
1414

15+
if (
16+
options.extractManifest != null &&
17+
typeof options.extractManifest !== "boolean"
18+
) {
19+
throw new TypeError("Extract manifest must be boolean");
20+
}
21+
22+
this.extractManifest = options.extractManifest != null
23+
? options.extractManifest
24+
: true;
25+
1526
const manifestPlugins = options.manifestPlugins;
1627

1728
if (manifestPlugins && !Array.isArray(manifestPlugins)) {
@@ -89,7 +100,9 @@ class InlineChunkManifestHtmlWebpackPlugin {
89100
}
90101

91102
applyDependencyPlugins(compiler) {
92-
this.plugins.forEach(plugin => plugin.apply.call(plugin, compiler));
103+
if (this.extractManifest) {
104+
this.plugins.forEach(plugin => plugin.apply.call(plugin, compiler));
105+
}
93106
}
94107
}
95108

test/plugin-init-test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,30 @@ test("override drop asset", t => {
2626
t.is(plugin.dropAsset, true);
2727
});
2828

29+
test("extract manifest as boolean", t => {
30+
const error = t.throws(() => {
31+
const plugin = new InlineChunkManifestHtmlWebpackPlugin({
32+
extractManifest: 1
33+
});
34+
}, TypeError);
35+
36+
t.is(error.message, "Extract manifest must be boolean");
37+
});
38+
39+
test("default extract manifest", t => {
40+
const plugin = new InlineChunkManifestHtmlWebpackPlugin();
41+
42+
t.is(plugin.extractManifest, true);
43+
});
44+
45+
test("disable plugins", t => {
46+
const plugin = new InlineChunkManifestHtmlWebpackPlugin({
47+
extractManifest: false
48+
});
49+
50+
t.is(plugin.extractManifest, false);
51+
});
52+
2953
test("override manifest filename", t => {
3054
const plugin = new InlineChunkManifestHtmlWebpackPlugin({
3155
filename: "another.file"

0 commit comments

Comments
 (0)