This repository was archived by the owner on Jun 8, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +40
-2
lines changed Expand file tree Collapse file tree 3 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,8 @@ const inlineChunkManifestConfig = {
42
42
manifestVariable: ' webpackManifest' , // webpackManifest is default
43
43
chunkManifestVariable: ' webpackChunkManifest' , // webpackChunkManifest is default; use in html-webpack-plugin template
44
44
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
46
47
};
47
48
48
49
new InlineChunkManifestHtmlWebpackPlugin (inlineChunkManifestConfig)
Original file line number Diff line number Diff line change @@ -12,6 +12,17 @@ class InlineChunkManifestHtmlWebpackPlugin {
12
12
options . chunkManifestVariable || "webpackChunkManifest" ;
13
13
this . dropAsset = options . dropAsset || false ;
14
14
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
+
15
26
const manifestPlugins = options . manifestPlugins ;
16
27
17
28
if ( manifestPlugins && ! Array . isArray ( manifestPlugins ) ) {
@@ -89,7 +100,9 @@ class InlineChunkManifestHtmlWebpackPlugin {
89
100
}
90
101
91
102
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
+ }
93
106
}
94
107
}
95
108
Original file line number Diff line number Diff line change @@ -26,6 +26,30 @@ test("override drop asset", t => {
26
26
t . is ( plugin . dropAsset , true ) ;
27
27
} ) ;
28
28
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
+
29
53
test ( "override manifest filename" , t => {
30
54
const plugin = new InlineChunkManifestHtmlWebpackPlugin ( {
31
55
filename : "another.file"
You can’t perform that action at this time.
0 commit comments