Skip to content

Commit 5d05136

Browse files
committed
Refactor JsonpMainTemplatePlugin
1 parent ae6c7a4 commit 5d05136

File tree

1 file changed

+10
-22
lines changed

1 file changed

+10
-22
lines changed

lib/web/JsonpMainTemplatePlugin.js

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,16 @@ class JsonpMainTemplatePlugin {
2828
}
2929
return false;
3030
};
31-
// TODO refactor this
32-
if (!mainTemplate.hooks.jsonpScript) {
33-
mainTemplate.hooks.jsonpScript = new SyncWaterfallHook([
34-
"source",
35-
"chunk",
36-
"hash"
37-
]);
38-
}
39-
if (!mainTemplate.hooks.linkPreload) {
40-
mainTemplate.hooks.linkPreload = new SyncWaterfallHook([
41-
"source",
42-
"chunk",
43-
"hash"
44-
]);
45-
}
46-
if (!mainTemplate.hooks.linkPrefetch) {
47-
mainTemplate.hooks.linkPrefetch = new SyncWaterfallHook([
48-
"source",
49-
"chunk",
50-
"hash"
51-
]);
52-
}
31+
32+
["jsonpScript", "linkPreload", "linkPrefetch"].forEach(hook => {
33+
if (!mainTemplate.hooks[hook]) {
34+
mainTemplate.hooks[hook] = new SyncWaterfallHook([
35+
"source",
36+
"chunk",
37+
"hash"
38+
]);
39+
}
40+
});
5341

5442
const getScriptSrcPath = (hash, chunk, chunkIdExpression) => {
5543
const chunkFilename = mainTemplate.outputOptions.chunkFilename;

0 commit comments

Comments
 (0)