Vite issue with using local/custom fonts
I'm trying to load a custom font:
getting this error with vite:
Error: Dynamic require of "path" is not supported
My vite config file:
How to fix?
@font-face {
font-family: "Bellafair-Regular";
src: local("@/assets/fonts/Bellefair-Regular.ttf") format("truetype");
// src: local('Opensans-Bold'), url(@/assets/styles/fonts/OpenSans-Bold.ttf) format('truetype');
}getting this error with vite:
Error: Dynamic require of "path" is not supported
My vite config file:
const path = require("path");
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
export default defineConfig({
plugins: [react(), dynamicImport(/* options */)],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
});How to fix?
