When used with gulp watch all js files are being rebuilt
See original GitHub issueWhen webpack-stream is used in a gulp watch task it rebuilds all files, resulting in slow compile time.
This is my gulpfile with all webpack settings within:
var gulp = require('gulp'),
util = require('gulp-util'),
sass = require('gulp-sass'),
webpack = require('webpack');
webpackStream = require('webpack-stream');
gulp.task('webpack', function () {
return gulp.src('./build/scripts/entry.js')
.pipe(webpackStream({
entry: './build/scripts/entry.js',
output: {
path: __dirname + '/public/scripts',
filename: 'bundle.js'
},
resolve: {
extensions: ['', '.webpack.js', '.web.js', '.js', '.ts']
}
}, webpack, function (err, stats) {
console.log(stats.toString({ colors: true }));
}))
.pipe(gulp.dest('./public/scripts'));
});
gulp.task('scss', function () {
return gulp.src('./build/styles/**/*.scss')
.pipe(sass())
.pipe(gulp.dest('./public/styles'));
});
gulp.task('watch', function () {
gulp.watch('./build/scripts/**/*.js', ['webpack']);
gulp.watch('./build/styles/**/*.scss', ['scss']);
});
If I just use webpack --watch, only the edited file will be rebuilt, not working with above gulp webpack-stream.
Issue Analytics
- State:
- Created 7 years ago
- Comments:8
Top Results From Across the Web
How do I watch multiple files with gulp-browserify but process ...
Just call a normal task on file change, like this: gulp.task("build-js", function() { return gulp.src('src/js/app.js') .pipe(browserify()) ...
Read more >Watching Files | gulp.js
The watch() API connects globs to tasks using a file system watcher. It watches for changes to files that match the globs and...
Read more >gulp watch not watching js files ? - Laracasts
Hello. I am using Gulp with Elixir and coffee script but it only compiles what i make a change in the less files...
Read more >Moving from gulp 3 to 4 | Web Development - UConn Blogs
In both cases, the result will be basically the same. When the command gulp watch is run, the sass and js files will...
Read more >Using Gulp 4 in your workflow for Sass and JS files
gulp — runs everything in the gulpfile.js. We're exporting just the specific gulp functions that we will be using, like src , dest...
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
@jswny If I run my task
webpack
it will build my files, if I addwatch: true
, then I can’t run multiple task etc:gulp.task('build', ['webpack', 'styles']);
. It will still be in watch mode and not execute following tasks. Makes sense?But I found a way, if I do a simple gulp watch and watch my files instead of adding
watch: true
I will achieve what I want. Just got confused by the whole, where to watch as the readme had an example to use it inside my webpack config.I dont know if it’s fixed, definitely required some workaround and alot of fiddle. I’m closing for now, hopefully others who end in my struggle can learn from this 😃