[英]Cannot use vinylPaths del with gulp
I have the following gulp task, basically what it does is: 我有以下gulp任务,基本上它的作用是:
theme/app
folder theme/app
文件夹 theme/app
folder theme/app
文件夹中的所有文件 theme/app
folder to a single file theme/app
文件夹中的所有文件合并为一个文件 theme
theme
theme/app
folder theme/app
文件夹中的所有文件 I cannot make work the last step, I need to delete all files in theme/app
. 我无法进行最后一步,需要删除
theme/app
所有文件。 I have not specific error, what could could be wrong in my script and how to solve it? 我没有特定的错误,我的脚本中可能有什么错误以及如何解决?
gulp.task('_release-theme:compile', function () {
gulp.src([
'app/**/*.styl',
'!app/**/**mixins**.styl',
'!app/**/**variables**.styl',
])
.pipe(stylus({
compress: false,
use: nib()
}))
.pipe(gulp.dest('theme/app'))
.pipe(cleanCSS())
.pipe(concat('theme.css'))
.pipe(header(fs.readFileSync('licenses/app.txt', 'utf8')))
.pipe(gulp.dest('theme/'))
.pipe(vinylPaths(del['theme/app/**/*'])); // problem here
});
del
is a function. del
是一个函数。 Your object property access del['theme/app/**/*']
makes no sense here. 您的对象属性访问
del['theme/app/**/*']
在这里毫无意义。
Instead listen for the end
event in your stream and then delete the files using rimraf
: 而是侦听流中的
end
事件,然后使用rimraf
删除文件:
var rimraf = require('rimraf');
gulp.task('_release-theme:compile', function (done) {
gulp.src([
'app/**/*.styl',
'!app/**/**mixins**.styl',
'!app/**/**variables**.styl',
])
.pipe(stylus({
compress: false,
use: nib()
}))
.pipe(gulp.dest('theme/app'))
.pipe(cleanCSS())
.pipe(concat('theme.css'))
.pipe(header(fs.readFileSync('licenses/app.txt', 'utf8')))
.pipe(gulp.dest('theme/'))
.on('end', function() {
rimraf('theme/app/**/*', done);
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.