-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(LayoutPlugin): allow to set and pass crossOrigin for styles and scripts #46
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,13 +65,14 @@ export function createLayoutPlugin({ | |
...jsAssets.map((js) => ({ | ||
src: getAbsoluteUrl(publicPath, js, options?.prefix), | ||
defer: true, | ||
crossOrigin: 'anonymous' as const, | ||
crossOrigin: options.scriptsCrossOrigin || 'anonymous', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know where else crossOrigin may be needed. We encountered situation, that we need it only for stylesheets. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, fair enough, i've added the same settings for this case |
||
})), | ||
); | ||
|
||
renderContent.styleSheets.push( | ||
...cssAssets.map((css) => ({ | ||
href: getAbsoluteUrl(publicPath, css, options?.prefix), | ||
crossOrigin: options.stylesCrossOrigin, | ||
})), | ||
); | ||
} else { | ||
|
@@ -80,19 +81,40 @@ export function createLayoutPlugin({ | |
return getAbsoluteUrl(publicPath, manifestEntries[name], options?.prefix); | ||
}; | ||
renderContent.scripts.push( | ||
{src: getWebpackAssetUrl('runtime.js'), defer: true, crossOrigin: 'anonymous'}, | ||
{src: getWebpackAssetUrl('vendors.js'), defer: true, crossOrigin: 'anonymous'}, | ||
{src: getWebpackAssetUrl('commons.js'), defer: true, crossOrigin: 'anonymous'}, | ||
{ | ||
src: getWebpackAssetUrl('runtime.js'), | ||
defer: true, | ||
crossOrigin: options.scriptsCrossOrigin || 'anonymous', | ||
}, | ||
{ | ||
src: getWebpackAssetUrl('vendors.js'), | ||
defer: true, | ||
crossOrigin: options.scriptsCrossOrigin || 'anonymous', | ||
}, | ||
{ | ||
src: getWebpackAssetUrl('commons.js'), | ||
defer: true, | ||
crossOrigin: options.scriptsCrossOrigin || 'anonymous', | ||
}, | ||
{ | ||
src: getWebpackAssetUrl(`${options.name}.js`), | ||
defer: true, | ||
crossOrigin: 'anonymous', | ||
crossOrigin: options.scriptsCrossOrigin || 'anonymous', | ||
}, | ||
); | ||
renderContent.styleSheets.push( | ||
{href: getWebpackAssetUrl('vendors.css')}, | ||
{href: getWebpackAssetUrl('commons.css')}, | ||
{href: getWebpackAssetUrl(`${options.name}.css`)}, | ||
{ | ||
href: getWebpackAssetUrl('vendors.css'), | ||
crossOrigin: options.stylesCrossOrigin, | ||
}, | ||
{ | ||
href: getWebpackAssetUrl('commons.css'), | ||
crossOrigin: options.stylesCrossOrigin, | ||
}, | ||
{ | ||
href: getWebpackAssetUrl(`${options.name}.css`), | ||
crossOrigin: options.stylesCrossOrigin, | ||
}, | ||
); | ||
} | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only allows you to change the default to "use-credentials", right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I left "anonymous" as default. But for consistency added scriptsCrossOrigin as possible option.