Skip to content
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

Valet won't load changes Gulp makes to an HTML file #782

Closed
jalendport opened this issue May 17, 2019 · 9 comments
Closed

Valet won't load changes Gulp makes to an HTML file #782

jalendport opened this issue May 17, 2019 · 9 comments

Comments

@jalendport
Copy link

I've got a static site (using the BasicValetDriver) running locally. I'm using Gulp to compile Twig templates to an HTML file. I can verify that Gulp is indeed firing and that HTML file is updating any time I update a Twig file.

The problem I'm running into is that when I go to reload my browser, it doesn't pull in the new file; I'm still getting the old HTML file in the browser. I've tried reloading, shift-reloading, clearing the browser cache, running with and without BrowserSync, everything. The only way to make the browser recognize the HTML file updated is to manually go in and re-save the HTML file in my code editor. However, if I load the HTML file in the browser manually (via the absolute path), it updates every single time.

My conclusion is that Valet is somehow caching the html value and that cache breaks any time the html file changes, and for some reason Gulp isn't triggering that while my manual edits do. This is super weird and it's holding me up from working on this project right now... 😬

@jalendport
Copy link
Author

@drbyte any thoughts?

@drbyte
Copy link
Contributor

drbyte commented May 18, 2019

I'm not aware of any intentional caching that Valet would be doing.

And in a traditional install it seems to work fine with recognizing local updates.
For example, when I use "watch" mode with Laravel Mix it properly recognizes my content changes in the browser.

Sounds like you've tried all the usual suspects that I'd be checking.
Maybe you've added some sort of cache headers in your browser or your PHP code? Does Twig have settings for that? Page-Cache systems typically look for a content-changed indicator from the filesystem to know whether they should reload the content.

@drbyte
Copy link
Contributor

drbyte commented Aug 17, 2019

@jalendport Does this issue still need to be kept open? If so, please provide additional context.

@jalendport
Copy link
Author

Hey @drbyte; I never did solve the issue but ended up using another solution because I had a deadline fast approaching. I'm going to close it for now as I don't have the need anymore to debug it and it seems like I'm the only one who's run into it so far... Thanks for your help!

@RyanRoberts
Copy link

hey @jalendport I know you said above you didn't solve the problem but I'm having the exact same issue, did you ever get to the bottom of it? Or what was your other solution? Thanks.

@jalendport
Copy link
Author

@RyanRoberts are you using Twig.js as well? I never did get to the bottom of it, but I ended up just switching to plain PHP because all I was using Twig for was to have partials that I could include in multiple places.

@RyanRoberts
Copy link

@jalendport I do use twig but in this case I'm using Nunjucks (quite similar). However I've just loaded up Craft Nitro and the problem is still present, so it's not Valet. I've also noticed it only happens if I edit and save includes or layouts, not the page's corresponding njk/twig index file.

But something about this rings a bell, I think I've dealt with it before and it may have been caused by Gulp not updating the compiled file's modified time. Or something like that, I'll have a look through an older project and see what I'd done.

@RyanRoberts
Copy link

@jalendport OK so this issue in the Sass repo explains what I think is the problem: dlmanning/gulp-sass#706 - it appears to have been a change with Gulp 4 which packages had to account for. Gulp-Sass got updated but I don't think Gulp-Twig has been updated in a few years.

Scroll to the bottom and you'll find a solution using through2 that's working for me 👍

@jalendport
Copy link
Author

jalendport commented Jun 6, 2020

Awesome; good to know in case I ever run into it again 👏

Thanks for reporting back!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants