Referencing a font-face for a local file produces wrong paths when using run build.
Example structure:
/src
/assets
/fonts
fonts.css
font.ttf
In fonts.css i reference the font as url(./font.ttf) since they're in the same directory. After run build it produces the following css in static/css.
url(./static/media/font.ttf)
build folder structure
/static
/css
main.css
/media
font.ttf
So the css is looking for the font file in css/static/media/font.tff, when it should really be ../media/font.ttf
After run build it produces the following css in static/css.
I can鈥檛 reproduce this with default settings.
Do you have a homepage field in package.json?
If yes, what is it set to?
./
That鈥檚 where the issue comes from. I guess we just don鈥檛 support the use case of building when root application path is unknown.
We鈥檒l offer an escape hatch in 0.5.0 with a public folder though so maybe you could use that as a last resort if you really need to deploy the same build to different paths.
Ohh i see. Alright thanks. Will use a cdn in the mean time
馃憤
Hi there! react-scripts v0.9.0 was just released which adds support for building for relative paths. You may read how to do so here.
Please test it and don't hesitate to reach out if this doesn't solve your specific use case!
I have a similar issue and found that this solution solved my problem: got wrong bootstrap font path after building
Most helpful comment
I can鈥檛 reproduce this with default settings.
Do you have a
homepagefield inpackage.json?If yes, what is it set to?