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
Watching files on network drive triggers build task constantly #1116
Comments
Can you please include all of your paths? I have a feeling you might be watching a path that is also one of your output folders |
I wish it was that simple!
Destination for CSS is "assets/styles" and for JS it is "assets/script". No conflicts. And here's the kicker. When I moved the files to my local drive form my network drive it just works. Same config. |
I am new to Gulp and have faced the same problem. With me, I was using 'gulp-uglify', which minifies the js file. See if it works for you: gulp.task('scripts', function(){
gulp.src(['public/assets/js/**/*.js', '!public/assets/js/**/*.min.js'])
.pipe( rename({suffix:'.min'}) )
.pipe( uglify() )
.pipe( gulp.dest('public/assets/js') );
}); In this task, I am basically taking all the js files that don't have '.min' extension and uglifying them. The problem was with my watcher: gulp.task('watch', function(){
gulp.watch('public/assets/js/**/*.js', ['scripts'])
.on('change', function(evt){
console.log('[watcher] File ' + evt.path.replace(/.*(?=js)/,'') + ' was ' + evt.type + ', uglifying...');
});
}); For some reason, the watch task is always triggering 'script' task, because of the minified js file changes. I did include a '!public/assets/js/_/_.min.js' on script task, but it was still listening to the minified files. gulp.task('watch', function(){
gulp.watch(['public/assets/js/**/*.js', '!public/assets/**/*.min.js'], ['scripts'])
.on('change', function(evt){
console.log('[watcher] File ' + evt.path.replace(/.*(?=js)/,'') + ' was ' + evt.type + ', uglifying...');
});
}); Now the scripts task is only triggering once when it changes. I hope it works for you. |
Unfortunately as I wrote in my previous response my assets-files are outside of the source folder. And everything works just fine when I move the project to a local folder. The only difference is the network-folder. |
I can confirm the same result as @JonWallsten - I'm using Parallels on my Mac and my files are on the Mac side, shared with Windows as a network drive. If I run Gulp on Mac OS, it works fine. If I copy the files to the Windows C: drive, it also works as expected. Only when running Gulp on Windows with the files on the network share do I get the repeated file change events. |
I have the exact same setup. Boot camp Win 8.1 partition as virtual machine with Parallels. Files is located on the Mac and mapped as Network drive. |
I am experiencing this as well. I suspect this is an issue with Parallels because a coworker of mine using VM Fusion isn't running into this issue and neither are my other coworkers who aren't using any VM. |
I'm experiencing a similar issue, but my environment might differ slightly. I run the website/gulp inside of a virtual machine, and my host uses a network share to run the code editor. When I save a file, the gulp.watch inside the VM fires, but I noticed that the gulp.dest() function doesn't actually do anything --- any modified files in the stream get placed into the source directory -- which in this case is my ./scss directory, which again triggers gulp.watch (src = ./scss/*/) I can fix it by only watching for the ./scss/*.scss files, but the gulp.dest still places processed files inside of that directory. I'm not sure if the bug is with gulp.watch, gulp,dest or gulp-sass -- or none of the above and with nodejs itself on how a network file save triggers differently. (grunt works just fine) |
See the Parallels Forum at https://forum.parallels.com/threads/grunt-gulp-watch-from-windows-guest-to-mounted-mac-drive.328830/#post-776203 for a more official response. |
@pdeffendol Thanks for asking over there. So, it's not a gulp or gaze issue, then? |
@callumacrae Yes, it appears to be related to Parallels implementation of shared folders. I tried to test in VirtualBox but got some unrelated errors and |
It may not be only related to parallels. I'm experiencing the issue in a pure Windows environment as well. Even putting in an absolute path into the gulp.dest() doesn't work. |
@callumacrae For me it sounds like he's stating that the problem is with Parallels, but he's leaving the whole "when it's gonna be fixed" part of the statement. |
Can this be tested with the newest changes from the 4.0 branch? We've recently switched to chokidar as the watching library. |
I seem to be running into this issue as well the only difference is that I have it running off a USB drive mounted in OSX Yosemite. If I move the contents onto the internal drive it runs fine, and, incidentally, if I have the contents on a network mounted drive it works fine as well, the problem seems to only exist if running off the external drive. |
@arvinkx what version of gulp? This shouldn't be happening with the newest changes in the 4.0 branch because we switched to chokidar |
@phated I briefly tested with the 4.0 branch. It seems to work with |
@es128 ^ thoughts? |
Yup, the need for paulmillr/chokidar#242 tracks ideas about solving this in a more automatic way so users won't need to intervene with the |
@phated I was using a pre-4.0 version, I upgraded to 4.0 and it seems to have solved the problem in regards to an external (USB) drive. Thanks again. |
Closing this, as I believe it is resolved by chokidar in 4.0 (might need to use |
I can confirm this bug still exists when using usePolling: true and version 4.0 on a mounted network drive. |
For some reason my watch constantly triggers the change event. As soon as the build of styles is complete it triggers another one.
Paths is an array of paths. Does this have something to do with the fact that the files are on a network drive? Tried to google it and checked the previous issues, but could find any useful.
Log
Any ideas?
The text was updated successfully, but these errors were encountered: