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

Watch omits files #261

Closed
cranesandcaff opened this issue Feb 11, 2014 · 22 comments
Closed

Watch omits files #261

cranesandcaff opened this issue Feb 11, 2014 · 22 comments

Comments

@cranesandcaff
Copy link

When using gulp.watch it will for some reason completely omit a file when saved.

gulp.task('script', function(){
return gulp.src(['js/**/*.js'])
    .pipe(concat('appmain.js'))
    .pipe(gulp.dest('build/js'))
    .pipe(rename({suffix: '.min'}))
    .pipe(ngmin())
    .pipe(uglify({mangle: false}))
    .pipe(gulp.dest('build/js'))
   });
  gulp.task('watch', function(){
  gulp.watch('scss/**/*.scss', ['styles']);

  gulp.watch('js/**/*.js', ['script']);


})

When using gulp watch sometimes it will stop adding a file, for instance if I am working on 'functionOne.js" it will continue updating and minifying, then it will stop and when checking the concated appmain.js the code from 'functionOne.js' doesn't appear.

However if I then run 'gulp script' it will appear. If I then start watching again it will still not include that file.

@yocontra
Copy link
Member

Reformatted for reading

gulp.task('script', function () {
  return gulp.src(['js/**/*.js'])
    .pipe(concat('appmain.js'))
    .pipe(gulp.dest('build/js'))
    .pipe(rename({
      suffix: '.min'
    }))
    .pipe(ngmin())
    .pipe(uglify({
      mangle: false
    }))
    .pipe(gulp.dest('build/js'));
});

gulp.task('watch', function () {
  gulp.watch('scss/**/*.scss', ['styles']);
  gulp.watch('js/**/*.js', ['script']);
});

@cranesandcaff
Copy link
Author

Thank you for the reformatting.

I believe I may have figured it out. I read in a different issue that gulp.watch stops on an error, I believe a bad bracket may have caused ngmin to throw an error thus halting gulp.watch, however this doesn't cause gulp to stop watching or compiling files it just has gulp discard the bad files.

Is there a way to set up that it will end on an error? Perhaps make that a default?

@cranesandcaff
Copy link
Author

I tried playing around with it to see if I could fix this. So far

gulp.task('script', function(){
    return gulp.src(['js/**/*.js'])
        .pipe(concat('appmain.js'))
        .pipe(gulp.dest('build/js'))
        .pipe(rename({suffix: '.min'}))     
        .pipe(gulp.dest('build/js'))
 });

The above works fine with gulp script

gulp.task('watchJS', function(){
        gulp.watch('js/**/*.js', ['script']);
})

The above however removes any file I edit from the final build.

@yocontra
Copy link
Member

So your files in js/**/*.js are not order sensitive?

Can you post what the correct output should be, and what the incorrect output is?

@cranesandcaff
Copy link
Author

I don't believe they are very order sensitive. I haven't ran into an issue with that.

For example, I have

fileOne.js
fileTwo.js
fileThree.js

When I run gulp script I get a file appmain.min.js which has fileOne.js, fileTwo.js, and fileThree.js all concatenated.

If I run gulp watch at first all three will be there however if I edit say fileThree.js now appmain.min.js will only contain fileOne.js and fileTwo.js

@yocontra
Copy link
Member

@cranesandcaff Can you use gulp-debug between src and concat and post the logs from a broken scenario?

@cranesandcaff
Copy link
Author

Sure can. I wasn't aware of that. I'll throw it in and set it to watch.

@cranesandcaff
Copy link
Author

File
cwd: /var/www/html/chmorders/chmcurrent/public
base: /var/www/html/chmorders/chmcurrent/public/js/
path: /var/www/html/chmorders/chmcurrent/public/js/controllers/createOrder.js
contents: ...
File
cwd: /var/www/html/chmorders/chmcurrent/public
base: /var/www/html/chmorders/chmcurrent/public/js/
path: /var/www/html/chmorders/chmcurrent/public/js/services/session.js
contents: angular.module('chm').factory('SessionSe...

[gulp] gulp-debug: end event fired (2014-02-12 19:07:11 UTC)
[gulp] Finished 'script' in 73 ms

I removed everything except the file that isn't being included and one other file for reference.

@yocontra
Copy link
Member

Does appmain.js contain all of the files or is appmain.min.js the only problem?

@cranesandcaff
Copy link
Author

appmain.js doesn't contain them all either.

where it says contents: ... it should say contents: angular.module('chm').controller('....

@yocontra
Copy link
Member

@yocontra
Copy link
Member

Can I see your full gulpfile?

@cranesandcaff
Copy link
Author

@toutpt
Copy link

toutpt commented Feb 26, 2014

My 2 cents: you don't need gulp-watch plugin, watch is a native feature of gulp and here you are using this one.

@cranesandcaff
Copy link
Author

I have the same issue using the gulp watch that is generated from the Yeoman gulp-webapp scaffold. It omits the stylesheet if I am working on it.

@toutpt
Copy link

toutpt commented Feb 26, 2014

I have been it by this bug, I was on 3.4, I have update to 3.5.2 and now every thing is working.

@cranesandcaff
Copy link
Author

I will try updating, thank you.

@cranesandcaff
Copy link
Author

I am on version 3.5.2 currently.

@cranesandcaff
Copy link
Author

Has anyone else had issue with this?

@yocontra
Copy link
Member

Closing due to #355 - this will be fixed in gulp 4.0

@yocontra
Copy link
Member

If it isn't fixed in 4.0 then it is related to gulpjs/glob-watcher#4

@cranesandcaff
Copy link
Author

Thank you for the update. I'll watch for Gulp 4.0! Thank you

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