-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prints unicode character instead of icon #48
Comments
Hey @labbydev it looks like you did everything correct 🤔 Can you try if it works for you with the It is using this configuration in the background: |
Adding in
|
It looks like perhaps the font file isn't correct. In the compiled result:
|
looks like the loader doesn't work - which webpack version do you use? |
I'm using version 4 (specifically 4.44.2) of Webpack |
In the example it works: https://github.com/jantimon/iconfont-webpack-plugin/blob/master/example/default/webpack.config.js I also created this codesandbox for you - maybe you can try to break it similar like on your project so we can find out what kind of configuration is causing it: https://codesandbox.io/s/icon-font-webpack-plugin-ku3qz?file=/webpack.config.js |
I have tried adding a copy of my webpack file in the sandbox here however, based on an inspect of the icon it doesn't appear to be using that configuration since it doesn't have the appropriate font name prefix appearing. I've tried a number of configurations and this is the only one that builds without errors (generally a large number of 'unknown word' errors about |
I experience the same issue, however with webpack 5. My SASS file looks similar to this:
Both files are in the "assets" folder and can be resolved by webpack. And everything seems to be in order here: The issue I think leads to the problem is, that the generated font file is invalid. The content is prefixed with module.exports="... which is probably not correct and leads to the issue, that the browser can't interpret the woff file and will therefore fail to render the correct icon. I'm not 100% sure if this is related, or it has to do with the webpack asset module syntax that was introduced in v5. |
As an appendix to my previous post: I can confirm, my issue comes from using the asset module logic, instead of the url-loader/file-loader in webpack 5. I fixed the issue by using the "generator" and "parser" options for the asset module:
This will ensure the icon font gets written as data-url and remove the module.exports from it. |
@Neunerlei is there anything we could do in the iconfont-webpack-plugin to prevent that? maybe we could use the https://webpack.js.org/api/loaders/#inline-matchresource or maybe even turn it into a binary so it can be statically extracted? |
@jantimon Hey there. What you are supposing could work, but I never tested that option myself, yet. One thing that would make it a lot easier would be to introduce a new option like: "esModule": false which disables the Module generation here and on line 35 What would really solve the problem is, to get rid of the dataUrl entirely in your loader. Your loader is in a twilight-zone, where webpack seems to run into its limits. I spent a lot of time, searching the internet on how to create a dynamic module, that handles like a real one. You would have multiple routes to go with, tho.
I personally would try option 2 first, because you don't need a plugin, have the benefit of keeping your woff source "virtual" and can handle the file as a real woff without any issues. Additionally, it should work without any updates in the webpack.config (Theoretically cough) I hope this helps :) |
Not sure if this is to overcomplicated..
the virual file will be picked up by all loaders defined for |
If that works 👍 |
Using the default config suggested in the
README
:font-icon: url('../../static/images/icons/search.svg');
I am seeing the unicode character instead of the referenced svg as the content. Please advise on how I can fix to see the icon or what steps I can take to debug.
The text was updated successfully, but these errors were encountered: