Open danielhollas opened 5 years ago
Pulled my comments from #1976 to a separate issue per @edemaine request. :-)
Not knowing Webpack super well, I thought I'd give a try at resolving this via pure less
. What's wrong with the following approach?
npx lessc --modify-var='font-folder=new-location' src/katex.less custom-katex.css
P.S. I don't think this is a bug. It's pretty much how you'd expect all the parts to work...
I am not sure I understand your approach. What would you do with the custom-katex.css file? I have next-to-nothing knowledge of webpack as well, so I do not know whether the current behaviour can be improved or not. All I am saying is that I was mega-confused why I was not getting my fonts in the build process.
@danielhollas I'd like to try reproducing this. What did you change the @font-folder
to in step 1?
Also, where can I find the source for the discourse plugin? Perhaps there's a change that could be made to that setup. We're in the process of changing how we ingest new KaTeX versions at KA and as part of that we've updated our webpack config using file-loader
to rewrite the paths for the font files as well as copy them to new location from within node_modules.
@kevinbarabash thanks for looking into this! Here's what I have:
@font-folder: "/plugins/discourse-math/katex/fonts";
Here's the plugin: https://github.com/discourse/discourse-math
KaTeX files are in public/katex
and the loading code is here.
Discourse has its own custom plugin system which I, unfortunately, do not understand in detail. But somehow the way the plugin assets are loaded screws up the relative path to fonts that is in normal katex.css
. For example, if I am in a topic on the forum with this URL:
"/t/slug/topic_id/
the relative path to fonts then results in 404 on the address:
"/t/slug/topic_id/fonts/Katex-XXX.woff2"
Describe the bug: When you modify
@font-folder
insubmodules/katex-fonts/fonts.less
(per these instructions), the build system will no longer find them insubmodules/katex-fonts/fonts/
and thedist/fonts/
folder will be missing in the build. Two-step process is needed in this case:fonts.less
file, and copydist/fonts/
folder where you need.fonts.less
and build again to get correctkatex.min.css
file.To Reproduce: Steps to reproduce the behavior:
@font-folder
insubmodules/katex-fonts/fonts.less
yarn build
dist/
folder will not contain fontsExpected behavior: IMO fonts should be fetched regardless of the value of
@font-folder
Additional context: I was rebuilding KaTeX for Discourse Math plugin, which requires:
@font-folder: "/plugins/discourse-math/katex/fonts";