Skip to content

Commit eca5a59

Browse files
author
wangzongxu
committed
feat: new hook miniCssExtractPluginBeforeLinkAppend
Allow the link tag to be added to the head before doing some extra processing, such as I want to set a load timeout listener
1 parent 1ffc393 commit eca5a59

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ const {
1313
Template,
1414
util: { createHash },
1515
} = webpack;
16+
const {
17+
SyncWaterfallHook,
18+
} = require("tapable");
1619

1720
const MODULE_TYPE = 'css/mini-extract';
1821

@@ -129,6 +132,8 @@ class MiniCssExtractPlugin {
129132

130133
apply(compiler) {
131134
compiler.hooks.thisCompilation.tap(pluginName, (compilation) => {
135+
compilation.hooks.miniCssExtractPluginBeforeLinkAppend = new SyncWaterfallHook(['source', 'chunk', 'hash'])
136+
132137
compilation.dependencyFactories.set(
133138
CssDependency,
134139
new CssModuleFactory()
@@ -377,6 +382,7 @@ class MiniCssExtractPlugin {
377382
])
378383
: '',
379384
'var head = document.getElementsByTagName("head")[0];',
385+
compilation.hooks.miniCssExtractPluginBeforeLinkAppend.call('', chunk, hash),
380386
'head.appendChild(linkTag);',
381387
]),
382388
'}).then(function() {',

0 commit comments

Comments
 (0)