File tree 2 files changed +12
-5
lines changed
2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,8 @@ export class PluginForHtmlWebpackPluginV3 extends BasePlugin {
17
17
private process ( data : HtmlWebpackPluginData ) {
18
18
// check if current html needs to be inlined
19
19
if ( this . isCurrentFileNeedsToBeInlined ( data . outputName ) ) {
20
- data . assets . css . forEach ( ( cssLink , index ) => {
20
+ const [ ...cssAssets ] = data . assets . css
21
+ cssAssets . forEach ( cssLink => {
21
22
const style = this . getCSSStyle ( {
22
23
cssLink,
23
24
publicPath : data . assets . publicPath ,
@@ -30,8 +31,11 @@ export class PluginForHtmlWebpackPluginV3 extends BasePlugin {
30
31
style : style ,
31
32
} )
32
33
34
+ const cssLinkIndex = data . assets . css . indexOf ( cssLink )
33
35
// prevent generate <link /> tag
34
- data . assets . css . splice ( index , 1 )
36
+ if ( cssLinkIndex !== - 1 ) {
37
+ data . assets . css . splice ( cssLinkIndex , 1 )
38
+ }
35
39
}
36
40
} )
37
41
Original file line number Diff line number Diff line change @@ -32,7 +32,8 @@ export class PluginForHtmlWebpackPluginV4 extends BasePlugin {
32
32
private cssStyleMap : Map < HTMLWebpackPlugin , CSSStyle [ ] > = new Map ( )
33
33
34
34
private prepareCSSStyle ( data : BeforeAssetTagGenerationData ) {
35
- data . assets . css . forEach ( ( cssLink , index ) => {
35
+ const [ ...cssAssets ] = data . assets . css
36
+ cssAssets . forEach ( cssLink => {
36
37
if ( this . isCurrentFileNeedsToBeInlined ( cssLink ) ) {
37
38
const style = this . getCSSStyle ( {
38
39
cssLink,
@@ -45,9 +46,11 @@ export class PluginForHtmlWebpackPluginV4 extends BasePlugin {
45
46
} else {
46
47
this . cssStyleMap . set ( data . plugin , [ style ] )
47
48
}
48
-
49
+ const cssLinkIndex = data . assets . css . indexOf ( cssLink )
49
50
// prevent generate <link /> tag
50
- data . assets . css . splice ( index , 1 )
51
+ if ( cssLinkIndex !== - 1 ) {
52
+ data . assets . css . splice ( cssLinkIndex , 1 )
53
+ }
51
54
}
52
55
}
53
56
} )
You can’t perform that action at this time.
0 commit comments