In Laravel 11 with vite I am loading a font in my .scss file:
src:url("../fonts/my-font.eot");
Vite build this into this css:
src:url(/build/assets/my-font.eot);
How can I tell vite to create relative URLs like:
src:url(./my-font.eot);
Absolute path would be fine to, if I could add my subdirectory /my-app. root
and publicDir
option have no effect. Maybe laravel plugin overwrites this?
I searched through the manual and tried a lot of options without success.
2
Answers
This does the trick, but it is experimental and feels like a hack. Also I don't know what
__assetsPath
does and if it exists. Found it in the documentation advanced-base-options.Adding
base: './'
in the Vite config file should work and the resulting build files should use relative instead of absolute file path.Vite config file:
But if wish to have absolute path with subdirectroy you can then simply specify
base: 'subfolder/build'
and resulting build files will have absolute paths (for e.g.): /subfolder/build/assets/filename.css