1
0
Fork 0
mirror of synced 2024-07-05 22:40:39 +12:00

Fix fonts not loading in builder preview in dev

This commit is contained in:
Andrew Kingston 2023-06-16 14:46:34 +01:00
parent 26a3106f34
commit 07c79ec592

View file

@ -12,9 +12,31 @@ const ignoredWarnings = [
"a11y-click-events-have-key-events",
]
const copyFonts = dest =>
viteStaticCopy({
targets: [
{
src: "../../node_modules/@fontsource/source-sans-pro",
dest,
},
{
src: "../../node_modules/remixicon/fonts/*",
dest,
},
],
})
export default defineConfig(({ mode }) => {
const isProduction = mode === "production"
const env = loadEnv(mode, process.cwd())
// Plugins to only run in dev
const devOnlyPlugins = [
// Copy fonts to an additional path so that svelte's automatic
// prefixing of the base URL path can still resolve assets
copyFonts("builder/fonts"),
]
return {
test: {
setupFiles: ["./vitest.setup.js"],
@ -60,18 +82,8 @@ export default defineConfig(({ mode }) => {
),
"process.env.SENTRY_DSN": JSON.stringify(process.env.SENTRY_DSN),
}),
viteStaticCopy({
targets: [
{
src: "../../node_modules/@fontsource/source-sans-pro",
dest: isProduction ? "fonts" : "builder/fonts",
},
{
src: "../../node_modules/remixicon/fonts/*",
dest: isProduction ? "fonts" : "builder/fonts",
},
],
}),
copyFonts("fonts"),
...(isProduction ? [] : devOnlyPlugins),
],
optimizeDeps: {
exclude: ["@roxi/routify"],