Skip to content

Commit

Permalink
feat: add crossOriginLoading option
Browse files Browse the repository at this point in the history
  • Loading branch information
chikara-chan committed Nov 21, 2018
1 parent eb218cc commit baefbb9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/index.js
Expand Up @@ -272,6 +272,7 @@ class MiniCssExtractPlugin {
const chunkMap = this.getCssChunkObject(chunk);
if (Object.keys(chunkMap).length > 0) {
const chunkMaps = chunk.getChunkMaps();
const { crossOriginLoading } = mainTemplate.outputOptions;
const linkHrefPath = mainTemplate.getAssetPath(
JSON.stringify(this.options.chunkFilename),
{
Expand Down Expand Up @@ -363,6 +364,17 @@ class MiniCssExtractPlugin {
]),
'};',
'linkTag.href = fullhref;',
crossOriginLoading
? Template.asString([
`if (linkTag.href.indexOf(window.location.origin + '/') !== 0) {`,
Template.indent(
`linkTag.crossOrigin = ${JSON.stringify(
crossOriginLoading
)};`
),
'}',
])
: '',
'var head = document.getElementsByTagName("head")[0];',
'head.appendChild(linkTag);',
]),
Expand Down

0 comments on commit baefbb9

Please sign in to comment.