File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed
Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change 1+ import fs from 'node:fs'
2+
13import partytown from '@astrojs/partytown'
24import sitemap from '@astrojs/sitemap'
35import tailwind from '@astrojs/tailwind'
@@ -29,5 +31,29 @@ export default defineConfig({
2931 sitemap ( ) ,
3032 purgecss ( ) ,
3133 compress ( ) ,
32- ]
34+ ] ,
35+ vite : {
36+ plugins : [ rawFonts ( [ '.ttf' , '.woff' ] ) ] ,
37+ optimizeDeps : {
38+ exclude : [
39+ '@resvg/resvg-js' ,
40+ ] ,
41+ } ,
42+ }
3343} )
44+
45+ // vite plugin to import fonts
46+ function rawFonts ( ext ) {
47+ return {
48+ name : 'vite-plugin-raw-fonts' ,
49+ transform ( _ , id ) {
50+ if ( ext . some ( ( e ) => id . endsWith ( e ) ) ) {
51+ const buffer = fs . readFileSync ( id )
52+ return {
53+ code : `export default ${ JSON . stringify ( buffer ) } ` ,
54+ map : null ,
55+ }
56+ }
57+ } ,
58+ }
59+ }
You can’t perform that action at this time.
0 commit comments