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
+
1
3
import partytown from '@astrojs/partytown'
2
4
import sitemap from '@astrojs/sitemap'
3
5
import tailwind from '@astrojs/tailwind'
@@ -29,5 +31,29 @@ export default defineConfig({
29
31
sitemap ( ) ,
30
32
purgecss ( ) ,
31
33
compress ( ) ,
32
- ]
34
+ ] ,
35
+ vite : {
36
+ plugins : [ rawFonts ( [ '.ttf' , '.woff' ] ) ] ,
37
+ optimizeDeps : {
38
+ exclude : [
39
+ '@resvg/resvg-js' ,
40
+ ] ,
41
+ } ,
42
+ }
33
43
} )
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