File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -42,5 +42,26 @@ export default (await import("astro/config")).defineConfig({
4242 devSourcemap : true ,
4343 transformer : "postcss" ,
4444 } ,
45+ plugins : [
46+ {
47+ name : "crossorigin" ,
48+ transform ( code , id , options ) {
49+ return code
50+ . replace ( / < s c r i p t / g, '<script crossorigin="anonymous"' )
51+ . replace (
52+ / < l i n k [ ^ > ] * (? = .* r e l = " p r e l o a d " ) (? = .* h r e f = " [ ^ " ] * \. j s " ) (? = .* a s = " s c r i p t " ) [ ^ > ] * / g,
53+ '$& crossorigin="anonymous"' ,
54+ )
55+ . replace (
56+ / < l i n k [ ^ > ] * (? = .* r e l = " p r e l o a d " ) (? = .* a s = " f o n t " ) [ ^ > ] * / g,
57+ '$& crossorigin="anonymous"' ,
58+ )
59+ . replace (
60+ / < l i n k [ ^ > ] * (? = .* r e l = " s t y l e s h e e t " ) (? = .* h r e f = " h t t p s ? : \/ \/ [ ^ " ] * " ) [ ^ > ] * / g,
61+ '$& crossorigin="anonymous"' ,
62+ ) ;
63+ } ,
64+ } ,
65+ ] ,
4566 } ,
4667} ) as typeof defineConfig ;
You can’t perform that action at this time.
0 commit comments