Skip to content

Commit 9443d77

Browse files
refactor: code
1 parent f836968 commit 9443d77

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/CssLoadingRuntimeModule.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ const getCssChunkObject = (mainChunk, compilation) => {
2727
};
2828

2929
module.exports = class CssLoadingRuntimeModule extends RuntimeModule {
30-
constructor(runtimeRequirements, insert) {
30+
constructor(runtimeRequirements, runtimeOptions) {
3131
super('css loading', 10);
3232
this.runtimeRequirements = runtimeRequirements;
33-
this.insert = insert;
33+
this.runtimeOptions = runtimeOptions;
3434
}
3535

3636
generate() {
@@ -78,7 +78,7 @@ module.exports = class CssLoadingRuntimeModule extends RuntimeModule {
7878
'}',
7979
])
8080
: '',
81-
this.insert,
81+
this.runtimeOptions.insert,
8282
'return linkTag;',
8383
]
8484
)};`,

src/index.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,13 @@ class MiniCssExtractPlugin {
5555
filename: DEFAULT_FILENAME,
5656
ignoreOrder: false,
5757
},
58-
options,
59-
{ insert }
58+
options
6059
);
6160

61+
this.runtimeOptions = {
62+
insert,
63+
};
64+
6265
if (!this.options.chunkFilename) {
6366
const { filename } = this.options;
6467

@@ -407,7 +410,7 @@ class MiniCssExtractPlugin {
407410
'}',
408411
])
409412
: '',
410-
this.options.insert,
413+
this.runtimeOptions.insert,
411414
]),
412415
'}).then(function() {',
413416
Template.indent(['installedCssChunks[chunkId] = 0;']),
@@ -445,7 +448,7 @@ class MiniCssExtractPlugin {
445448
);
446449
compilation.addRuntimeModule(
447450
chunk,
448-
new CssLoadingRuntimeModule(set, this.options.insert)
451+
new CssLoadingRuntimeModule(set, this.runtimeOptions)
449452
);
450453
};
451454
compilation.hooks.runtimeRequirementInTree

0 commit comments

Comments
 (0)