I'm using Grunt for compiling Less files on a server, the problem is when I upload the less file over the server using FTP client (Filezilla), the Grunt --watch task starts to compiling the less file from the very first byte that it receives before letting it to finish uploading completely, which cause the CSS file to be empty.
I need to be able to upload the file fully on the server then the Grunt Watch does its job, so I thought if there's a command to give Grunt a timeout delay like 2 seconds then start the task.
You can get a similar effect by letting watch trigger instantly but then triggering a wait task (from grunt-wait plugin) before your less task, something along the lines of:
less: {
dist: {
files: [{
expand: true,
cwd: 'yourdir',
src: '*.less',
dest: 'destdir',
ext: '.css'
}]
}
},
wait: {
ftp: {
options: {
delay: 2000
}
}
},
watch: {
less: {
files: ['yourdir/*.less'],
tasks: ['wait:ftp', 'less:dist']
}
},
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With