Gulp 重命名或删除文件夹后崩溃
Gulp crashes after renaming or deleting folders
Gulp 在更改文件夹名称或删除它们后崩溃。这是每个人都会遇到的常见问题吗?
// Task to copy images to dist.
gulp.task('copy-images', function() {
return gulp.src([
'images/*.{jpg,png,gif}',
'images/**/*.{jpg,png,gif}',
'node_modules/jquery-ui-bundle/images/*',
])
.pipe(gulp.dest('dist/images/'))
})
// Task to watch.
gulp.task('watch', function () {
// Watch all the fonts files recursively.
gulp.watch([
'images/**'
], [
'copy-images'
])
})
所以当我添加一个新文件夹logos1
时,我得到:
[10:58:31] Starting 'watch'...
[10:58:31] Finished 'watch' after 13 ms
[11:02:10] Starting 'copy-images'...
[11:02:10] Finished 'copy-images' after 58 ms
这是我所期望的。但是如果我 删除 logos1
和 添加 新文件夹 logos2
,gulp 崩溃:
events.js:183
throw er; // Unhandled 'error' event
^
Error: watch /var/www/html/xxx8/images/logos1 ENOENT
at _errnoException (util.js:1022:11)
at FSWatcher.start (fs.js:1382:19)
at Object.fs.watch (fs.js:1408:11)
抱怨logos1
我删了
有什么想法吗?有什么解决办法吗?
我用这两个包来解决问题:
代码:
gulp.task('watch', function () {
watch([
'images/**',
'images/**/*.{jpg,png,gif}'
], batch(function (events, done) {
gulp.start('copy-images', done)
}))
watch([
'fonts/**',
'fonts/**/*.{eot,svg,ttf,woff,woff2}'
], batch(function (events, done) {
gulp.start('copy-fonts', done)
}))
})
不再崩溃!
Gulp 在更改文件夹名称或删除它们后崩溃。这是每个人都会遇到的常见问题吗?
// Task to copy images to dist.
gulp.task('copy-images', function() {
return gulp.src([
'images/*.{jpg,png,gif}',
'images/**/*.{jpg,png,gif}',
'node_modules/jquery-ui-bundle/images/*',
])
.pipe(gulp.dest('dist/images/'))
})
// Task to watch.
gulp.task('watch', function () {
// Watch all the fonts files recursively.
gulp.watch([
'images/**'
], [
'copy-images'
])
})
所以当我添加一个新文件夹logos1
时,我得到:
[10:58:31] Starting 'watch'...
[10:58:31] Finished 'watch' after 13 ms
[11:02:10] Starting 'copy-images'...
[11:02:10] Finished 'copy-images' after 58 ms
这是我所期望的。但是如果我 删除 logos1
和 添加 新文件夹 logos2
,gulp 崩溃:
events.js:183
throw er; // Unhandled 'error' event
^
Error: watch /var/www/html/xxx8/images/logos1 ENOENT
at _errnoException (util.js:1022:11)
at FSWatcher.start (fs.js:1382:19)
at Object.fs.watch (fs.js:1408:11)
抱怨logos1
我删了
有什么想法吗?有什么解决办法吗?
我用这两个包来解决问题:
代码:
gulp.task('watch', function () {
watch([
'images/**',
'images/**/*.{jpg,png,gif}'
], batch(function (events, done) {
gulp.start('copy-images', done)
}))
watch([
'fonts/**',
'fonts/**/*.{eot,svg,ttf,woff,woff2}'
], batch(function (events, done) {
gulp.start('copy-fonts', done)
}))
})
不再崩溃!