File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed
packages/vite/src/node/plugins Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -675,6 +675,12 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
675
675
attrs : {
676
676
...( isAsync ? { async : true } : { } ) ,
677
677
type : 'module' ,
678
+ // crossorigin must be set not only for serving assets in a different origin
679
+ // but also to make it possible to preload the script using `<link rel="preload">`.
680
+ // `<script type="module">` used to fetch the script with credential mode `omit`,
681
+ // however `crossorigin` attribute cannot specify that value.
682
+ // https://developer.chrome.com/blog/modulepreload/#ok-so-why-doesnt-link-relpreload-work-for-modules:~:text=For%20%3Cscript%3E,of%20other%20modules.
683
+ // Now `<script type="module">` uses `same origin`: https://github.com/whatwg/html/pull/3656#:~:text=Module%20scripts%20are%20always%20fetched%20with%20credentials%20mode%20%22same%2Dorigin%22%20by%20default%20and%20can%20no%20longer%0Ause%20%22omit%22
678
684
crossorigin : true ,
679
685
src : toOutputPath ( chunk . fileName ) ,
680
686
} ,
You can’t perform that action at this time.
0 commit comments