Skip to content

Commit 126989b

Browse files
author
xiangmixue
committed
fix bug: cannot inline multiple css
1 parent 9ffc73a commit 126989b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/core/v4.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ export class PluginForHtmlWebpackPluginV4 extends BasePlugin {
3232
private cssStyleMap: Map<HTMLWebpackPlugin, CSSStyle[]> = new Map()
3333

3434
private prepareCSSStyle(data: BeforeAssetTagGenerationData) {
35-
data.assets.css.forEach((cssLink, index) => {
35+
const [...cssAssets] = data.assets.css
36+
cssAssets.forEach(cssLink => {
3637
if (this.isCurrentFileNeedsToBeInlined(cssLink)) {
3738
const style = this.getCSSStyle({
3839
cssLink,
@@ -45,9 +46,11 @@ export class PluginForHtmlWebpackPluginV4 extends BasePlugin {
4546
} else {
4647
this.cssStyleMap.set(data.plugin, [style])
4748
}
48-
49+
const cssLinkIndex = data.assets.css.indexOf(cssLink)
4950
// prevent generate <link /> tag
50-
data.assets.css.splice(index, 1)
51+
if (cssLinkIndex !== -1) {
52+
data.assets.css.splice(cssLinkIndex, 1)
53+
}
5154
}
5255
}
5356
})

0 commit comments

Comments
 (0)