Wrong gulp example?
See original GitHub issueI’ve integrated browser-sync in my gulp tool chain like this: http://www.browsersync.io/docs/gulp/#gulp-reload. The part I’m questioning is this one:
// create a task that ensures the `js` task is complete before
// reloading browsers
gulp.task('js-watch', ['js'], browserSync.reload);
Basically gulp is watching the js-directory and this ‘js-watch’ should be called every time a change is detected.
The problem I’ve experienced is, that this task never ends, looks like browserSync.reload never returns anything (in the command line i never see any ‘finished js-watch’ information) and the browser therefore reloads only once. Every change after the first one, won’t result in any browser reload, as the ‘js-watch’-task is still running.
The following code fixed this for me:
gulp.task('js-watch', ['scripts'], function(){
browserSync.reload();
return;
});
Issue Analytics
- State:
- Created 8 years ago
- Comments:13 (1 by maintainers)
Top Results From Across the Web
Gulp error: The following tasks did not complete - Stack Overflow
I've seen a few example Gulp 4 examples such as this one where watchers don't seem to be accompanied by completion signals. What...
Read more >Error management in gulp - gists · GitHub
Suppose you have a task in gulpfile. js that contains this code (we modified it a little bit to be closer to real-usage):...
Read more >My gulp clean task throwing me an error (Example) - Treehouse
Hi, I have a problem when i run the gulp clean task. tree... ... Error: Cannot find module 'gulp-sourcemaps' at Function.Module.
Read more >Getting Started with Gulp.js - Semaphore Tutorial
In this example, we capture the error event with .on('error') and call the callback with an Error instance. With return we ensure that...
Read more >Gulp for Beginners | CSS-Tricks
Gulp is a tool that helps you out with several tasks when it comes to web development. It's often used to do front...
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
Igladdy is 100% correct! This example worked for me. Note: Using Gulp 4
For what it’s worth, I came here after having this issue, but it wasn’t related to an anonymous function.
It was due to a change in how gulp processes watch tasks, which was way over my head, but explained in https://github.com/gulpjs/gulp/issues/1623 and https://github.com/gulpjs/gulp/issues/1624
An example of how to handle the done function properly is in this merge request that fixes the issue for Zurb Foundation: https://github.com/zurb/foundation-zurb-template/pull/37/files