Comments (5)
Hey. As readme says in top: Watch, that actually is an endless stream, so you should never get Task finished
with endless watch routine, but you can use similar syntax as gulp.watch
has - passing array of tasks to gulp-watch
.
I'm not good at coffeescript, but here some code for you:
First - you can just pipe watch to a less:
gulp.task 'less-styles', () ->
watch(glob: [
'src/styles/*.less',
'src/styles/font-awesome/font-awesome.less'
])
.pipe less(
paths: [pathModule.join(__dirname, 'less', 'includes')]
)
.on 'error', notify.onError
message: 'Error: <%= error.message %>',
title: 'Error in styles'
.on 'finish', () ->
console.log "FOO!"
.pipe gulp.dest './ui/styles'
)
Second - you can use gulp-debug
to see, which file was recompiled by less (if by any reason less is not printing files) or changed:
gulp.task 'less-styles', () ->
watch(glob: [
'src/styles/*.less',
'src/styles/font-awesome/font-awesome.less'
])
.pipe less(
paths: [pathModule.join(__dirname, 'less', 'includes')]
)
.on 'error', notify.onError
message: 'Error: <%= error.message %>',
title: 'Error in styles'
.pipe(debug())
.pipe gulp.dest './ui/styles'
)
If you really need exactly Task finished
message, then move out less to a gulp task:
gulp.task 'watch-less-styles', () ->
watch(glob: [
'src/styles/*.less',
'src/styles/font-awesome/font-awesome.less'
], ['less-styles'])
gulp.task 'less-styles', () ->
gulp.src 'src/styles/**/*.less'
.pipe less(
paths: [pathModule.join(__dirname, 'less', 'includes')]
)
.on 'error', notify.onError
message: 'Error: <%= error.message %>',
title: 'Error in styles'
.pipe gulp.dest './ui/styles'
)
from gulp-watch.
Thanks for your help! I ended up doing it like this:
gulp.task 'less-styles', () ->
watch(glob: [
'src/styles/*.less',
'src/styles/font-awesome/font-awesome.less'
])
.pipe print()
.pipe less(
paths: [pathModule.join(__dirname, 'less', 'includes')]
).on 'error', notify.onError
message: 'Error: <%= error.message %>',
title: 'Error in styles'
.pipe gulp.dest './ui/styles'
...which works well for me. Again, thank you! 😄
from gulp-watch.
I cant use this plugin with run-sequence
plugin because it never fires finish. Maybe you would add some options to turn off this endless stream? Because sometimes you want to run your tasks in a sequence but its hard with non controlled endless stream
from gulp-watch.
@pleerock how you imagine watch functionality to not be an 'endless'? Watch for some time?
In fact, you can. Because watch task should be without cb
:
gulp.task('watch', function () {
watch(src, function () { });
})
In this case, gulp will not wait for this task to end.
from gulp-watch.
Do a watch as a secondary function. Use less to compile (do the task and finish it), and less-watch to watch and compile
from gulp-watch.
Related Issues (20)
- Watched unexpected filepath
- Watched unexpected filepath
- Watched unexpected filepath
- Watched unexpected filepath
- subfolders no longer updating the main style.scss file
- Watched unexpected filepath
- How to deal with changed files? HOT 2
- watch is not working correctly
- chokidar version 3 HOT 4
- Watched unexpected filepath
- Watched unexpected filepath HOT 1
- please publish the latest version to npm
- chokidar version is too low
- Watched unexpected filepath
- Watched unexpected filepath HOT 1
- Watched unexpected filepath
- Watched unexpected filepath
- Watched unexpected filepath
- Watched unexpected filepath HOT 1
- Security Issue with Gulpwatch, fsevents and Request for Chokidar Version 3 and Fsevents Version 2 Installation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gulp-watch.