Infinite Loop on watch
See original GitHub issueSo it looks like the latest update causes an Infinite loop of watch when I import font-awesome.scss
file into my main app.scss
@import ‘…/…/plugins/fontawesome/font-awesome’;
Same thing happens for summernote & other plugins which work with font files.
Issue Analytics
- State:
- Created 7 years ago
- Comments:39 (2 by maintainers)
Top Results From Across the Web
VUE watch triggered infinite loop - Stack Overflow
The problem happens immediately where when i run the app, the watch for a variable is triggered in an infinite loop.
Read more >Infinity Loop for Apple Watch - Ownloop.com
Our continuous loop design has no buckles or clasps, so it won't irritate your skin. With 3 sizes to choose from, we guarantee...
Read more >Today at Apple - Activity - Infinite Loop
Learn, create, and be inspired in hands-on sessions at Apple Infinite Loop. ... to track your activities, health, and fitness with Apple Watch...
Read more >Infinite loop with Vue.js watchers - Get Help
I have a component that fetches data from an API endpoint and append it to an array (pictures[ ]). It's for a restaurant...
Read more >Infinite Loop - Apps on Galaxy Store
Introducing Infinite Loop Watch Face Features: - Premium Design - 5 Colors (Tap on watch face to change color) - High Quality Smooth...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
KNOWN SOLUTION (with explanation)
Ok, i know why this is happening now (and how to solve it), for both images and fontawesome. There is an option in Laravel Mix to process all files with relative urls. It is not really discussed in the documentation, but its functionality can be inferred through an option I found on this page of the documentation which offers a brief explanation: https://github.com/JeffreyWay/laravel-mix/blob/master/docs/options.md
processCssUrls: true
So this option defaults to true. It then goes forth to copy relative URLs it finds in the SASS file (presumably LESS also, but i have not tested), and copies these to relative locations in the public directory (so the urls will continue to work after moving the processed .css file to the
public/css
directory).To be honest, this functionality actually makes sense, so long as you are not trying to help Webpack, by putting the files in the public directory yourself (as i think we all where) it will work as intended. The idea is to put everything in the
resources/
folder and let webpack handle thepublic/
directory itself.Why FontAwesome Breaks this?
Because we pull the
fontawesome.scss
file into ourresources/sass
, it uses relative URLs to link to the font files. If you were putting the font files in thepublic/fonts
directory (as I was), then it caused a conflict because it is trying to copy the font files from where they already are to where they already are. I think this set it into some sort of infinite loop, instead of causing an actual error.How to solve: Put the font files inside
resources/fonts
and let them copy over to the public folder. After webpack processes, it will have put the files in the same place you wanted them to go anyway (public/fonts/
). As an alternative solution you could opt to install fontawesome via NPM, and require it from thenode_modules/
directory. After webpack processes, it will copy the font files from yournode_modules/
to yourpublic/fonts/
. If you prefer to manage the public folder yourself, read below to disable this.Why Do Public/Images Breaks this?
Once again, just like above, the relative urls used in things like
background-image
trigger webpack to try to “optimize and copy” the images. It is again trying to move the file from where it already is to replace it again. That is why moving the images to theresources/
folder works and so does putting them into any subfolder inside ofpublic/images/{{subfolder}}
. It works because then webpack can copy the image from the subfolder into thepublic/images
without a conflict.How to Solve: Put the images that you call in the SASS files, into
resources/images
and then when webpack runs it will “optimize and copy” them into yourpublic/images
folder at the root. If you prefer to manage the public folder yourself, read below to disable this.How to disable this functionality altogether?
If you prefer to manage your
public/
folder yourself and not have webpack attempt to copy and optimize things on your behalf then you can disable this functionality altogether. Simply go into yourwebpack.mix.js
file and add options onto the end of it to not process the relative urls.Your file will look like this, with the option disabled (defaults to true):
I have tested this in a fresh Laravel install. By setting this option to
false
, now both fontawesome and images placed inpublic/images
no longer goes into an infinite loop. When I remove the option or set the option totrue
, and i runnpm run watch
again, then it enters the loop. It solves this infinite loop problem!!!Tell your friends 😄 , happy coding!
It would be cool if we could have Laravel mix identify this and throw an error instead of going into an infinite loop which confuses new comers. At the very least we should document this in the documentation with the known solutions.
I have the same issue and I resolve this by adding mismatch images files use on css background rule with relative url.
My assets was:
In _fileA.scss I have this line:
In main.scss I have:
To solve the infinite lopp I add the image repository in my assets and it’s work well
(sorry for approximate english)