laravel-mix: copied svg asset broken
i’am using flag-icon-css, and loaded by mix, some of the svg assets copied by mix to public/fonts are broken, but when copied manuelly work.
This is my mix config:
const { mix } = require('laravel-mix');
mix.disableNotifications();
mix
.js('resources/assets/js/welcome/welcome-vendor.js', 'public/js')
.js('resources/assets/js/welcome/welcome.js', 'public/js')
.sass('resources/assets/sass/welcome/welcome-vendor.scss', 'public/css')
.sass('resources/assets/sass/welcome/welcome.scss', 'public/css')
.sourceMaps()
.version();
is there a way to tel me mix to not copy these dependencies, or to use a custom shell script to copy dependencies?
Thank you for mix.disableNotification() 😃
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 3
- Comments: 28 (12 by maintainers)
Lmao here we go again. I have already made a issue about this previously but I guess we will just wait for more issues to coming flowing in. I find it absurd that all svg’s are treated as fonts per default.
It seems that starting with laravel-mix v1.4.3 we can manipulate the webpack config before its handed over for processing.
So in the meantime something like this is possible:
I’m bothered too by the default behavior of Laravel Mix with SVG : putting them all in a fonts directory. I can’t find a good way to handle this issue, using mix.webpackConfig and the “smart” merging of config file lead to more issues, disabling processCssUrls or using absolute path cut some useful features.
SVG is mainly an image type not a font, and by the way SVG fonts support is quite anecdotal and will tend to disappear : “Removed from SVG 2.0 and considered as a deprecated feature with support being removed from browsers.” (http://caniuse.com/#feat=svg-fonts)…
Same thing here, mix is wrongly copying all svgs to the fonts folder, which is not the case all times (not every scalable vector graphic is a font, some of them can be just images). A way to reproduce my error case:
webpack.mix.js (default):
app.scss:
Fixed in #1367.
It is not a proper solution I am afraid.
The suggestion goes beyond laravel mix. If you’re using any library written by someone else, who pours their life into helping a community, and you feel like a hostage; run. Get as far away as possible.
This is about common sense. Saying “the package isn’t for you” is simply dismissive.
I have solved my problems and I am not here to argue about those, I am just sick and tired of seeing a community agreeing on a topic and not being heard.
But we all know what this boils down to. Jeffrey Way simply uses SVG’s as fonts and therefore this will not be changed.
Or we could just not shoot ourselves in the foot and treat SVG’s like images per default, since that is how the majority uses them.
I can’t believe this is still even something that should be discussed but ok, that is the hazard you get when you let a single developer take a community hostage.
It is a simple fix and it should be simple to fix. This should be fixed here however and not force a user to create a custom webpack configuration file themselves based on nothing more than an wrong assumption on how people will use this.
Found a possible solution. Commented in the related issue #1231.
I think we van all agree that most people seem to use them as images instead of fonts especially judging by the amount of issues already raised about this so far.
But yes if you want to know the truth you should have a poll which I guess will turn out about 95-5.
@JeffreyWay oh, it’s just that mix assumes always the fonts folder, but in the case of flag-icon-css, the svg files are in a folder called flags. I would want that mix would respect that file structure / give an option to disable automatic copying, so I can do it manually with mix.copy() and but it in a different folder than public/fonts.
Way to handle this.
That’s low. If having to add a few lines to your code to make a package work how you want, is holding you hostage, then maybe the package isn’t for you. Just use webpack and then you can configure every single detail exactly how you want.
So can we expect to see the default behaviour changed as @giovannipds has suggested?
@xsindesign well pointed. =)
@stephan-v I’m not suggesting to create a custom webpack config, I was just trying to help finding a way to fix it. =)
Isn’t this just simple changes on
webpack.config.js? Like so (from line 162 to 206):I am having the same issue. Copied SVGs are broken. Here is my mix file:
Also: I am just compiling the sass for flag-icon-css, but for some reason all svgs are getting copied automatically to public/fonts? This wasn’t the case with elixir.