Skip to content

Commit baefbb9

Browse files
committed
feat: add crossOriginLoading option
1 parent eb218cc commit baefbb9

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
{
@@ -363,6 +364,17 @@ class MiniCssExtractPlugin {
363364
]),
364365
'};',
365366
'linkTag.href = fullhref;',
367+
crossOriginLoading
368+
? Template.asString([
369+
`if (linkTag.href.indexOf(window.location.origin + '/') !== 0) {`,
370+
Template.indent(
371+
`linkTag.crossOrigin = ${JSON.stringify(
372+
crossOriginLoading
373+
)};`
374+
),
375+
'}',
376+
])
377+
: '',
366378
'var head = document.getElementsByTagName("head")[0];',
367379
'head.appendChild(linkTag);',
368380
]),

0 commit comments

Comments
 (0)