Skip to content

Commit 3df36ff

Browse files
committed
feat: add crossOriginLoading option
1 parent c12ddcb commit 3df36ff

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/index.js

+12
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ class MiniCssExtractPlugin {
272272
const chunkMap = this.getCssChunkObject(chunk);
273273
if (Object.keys(chunkMap).length > 0) {
274274
const chunkMaps = chunk.getChunkMaps();
275+
const { crossOriginLoading } = mainTemplate.outputOptions;
275276
const linkHrefPath = mainTemplate.getAssetPath(
276277
JSON.stringify(this.options.chunkFilename),
277278
{
@@ -365,6 +366,17 @@ class MiniCssExtractPlugin {
365366
]),
366367
'};',
367368
'linkTag.href = fullhref;',
369+
crossOriginLoading
370+
? Template.asString([
371+
`if (linkTag.href.indexOf(window.location.origin + '/') !== 0) {`,
372+
Template.indent(
373+
`linkTag.crossOrigin = ${JSON.stringify(
374+
crossOriginLoading
375+
)};`
376+
),
377+
'}',
378+
])
379+
: '',
368380
'var head = document.getElementsByTagName("head")[0];',
369381
'head.appendChild(linkTag);',
370382
]),

0 commit comments

Comments
 (0)