This repository was archived by the owner on Jun 8, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +16
-23
lines changed Expand file tree Collapse file tree 2 files changed +16
-23
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,14 @@ class InlineChunkManifestHtmlWebpackPlugin {
40
40
const chunkManifestVariable = this . chunkManifestVariable ;
41
41
const dropAsset = this . dropAsset ;
42
42
43
+ compiler . plugin ( "emit" , ( compilation , callback ) => {
44
+ if ( dropAsset ) {
45
+ delete compilation . assets [ manifestFilename ] ;
46
+ }
47
+
48
+ callback ( ) ;
49
+ } ) ;
50
+
43
51
compiler . plugin ( "compilation" , compilation => {
44
52
compilation . plugin (
45
53
"html-webpack-plugin-alter-asset-tags" ,
@@ -57,10 +65,6 @@ class InlineChunkManifestHtmlWebpackPlugin {
57
65
} ;
58
66
59
67
htmlPluginData . head . unshift ( newTag ) ;
60
-
61
- if ( dropAsset ) {
62
- delete compilation . assets [ manifestFilename ] ;
63
- }
64
68
}
65
69
66
70
callback ( null , htmlPluginData ) ;
Original file line number Diff line number Diff line change @@ -20,33 +20,22 @@ test.cb("keep asset", t => {
20
20
} ) ;
21
21
22
22
function isDropped ( dropAsset , callback ) {
23
- const assets = { } ;
24
- assets [ manifestFilename ] = {
23
+ const compilation = {
24
+ assets : { }
25
+ } ;
26
+ compilation . assets [ manifestFilename ] = {
25
27
source : ( ) => manifestFileContent
26
28
} ;
27
29
28
- const compilationPluginEvent = ( compilationEvent , alterAssets ) => {
29
- if ( compilationEvent === "html-webpack-plugin-alter-asset-tags" ) {
30
- const htmlPluginData = {
31
- head : [ ]
32
- } ;
33
-
34
- alterAssets ( htmlPluginData , ( _ , result ) => {
35
- const asset = assets [ manifestFilename ] ;
30
+ const pluginEvent = ( event , emit ) => {
31
+ if ( event === "emit" ) {
32
+ emit ( compilation , ( ) => {
33
+ const asset = compilation . assets [ manifestFilename ] ;
36
34
callback ( asset ) ;
37
35
} ) ;
38
36
}
39
37
} ;
40
38
41
- const pluginEvent = ( compilerEvent , compile ) => {
42
- const compilation = {
43
- plugin : compilationPluginEvent ,
44
- assets : assets
45
- } ;
46
-
47
- compile ( compilation ) ;
48
- } ;
49
-
50
39
const fakeCompiler = { plugin : pluginEvent } ;
51
40
52
41
const plugin = new InlineChunkManifestHtmlWebpackPlugin ( {
You can’t perform that action at this time.
0 commit comments