Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaRHristov committed Dec 19, 2024
1 parent 08d9b80 commit 37092b5
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,26 @@ export default (await import("astro/config")).defineConfig({
devSourcemap: true,
transformer: "postcss",
},
plugins: [
{
name: "crossorigin",
transform(code, id, options) {
return code
.replace(/<script/g, '<script crossorigin="anonymous"')
.replace(
/<link[^>]*(?=.*rel="preload")(?=.*href="[^"]*\.js")(?=.*as="script")[^>]*/g,
'$& crossorigin="anonymous"',
)
.replace(
/<link[^>]*(?=.*rel="preload")(?=.*as="font")[^>]*/g,
'$& crossorigin="anonymous"',
)
.replace(
/<link[^>]*(?=.*rel="stylesheet")(?=.*href="https?:\/\/[^"]*")[^>]*/g,
'$& crossorigin="anonymous"',
);
},
},
],
},
}) as typeof defineConfig;

0 comments on commit 37092b5

Please sign in to comment.