1
.SVG刪除我有一個咕嘟咕嘟任務在src文件夾中創建巴紐的.SVG文件回退:咕嘟咕嘟:刪除生成的從DEST png格式時,從SRC
gulp.task('svg2png', ['svg'], function() {
return gulp.src(src + '/svg/**/*.svg')
.pipe(plugins.newer(dest + '/svg'))
.pipe(plugins.svg2png())
.pipe(gulp.dest(dest + '/svg'))
.pipe(plugins.notify({
message: 'svg2png task complete', onLast: true
}));
});
(該svg
任務是svgmin)
我想通過刪除生成的文件(在DEST文件夾中)來整理自己的身後,認爲延伸如下表任務:
gulp.task('watch', function() {
var watchSvg = gulp.watch('src/svg/**/*.svg', ['svg2png']);
watchSvg.on('change', function(event) {
if (event.type === 'deleted') {
var filePathFromSrc = path.relative(path.resolve('src'), event.path);
var destFilePath = path.resolve('dist', filePathFromSrc);
del.sync(destFilePath);
}
});
});
這個作品在刪除.SVG但我希望阿爾斯o喜歡做的是刪除匹配的.png文件,所以沒有孤兒。我盲目地信任Handling the Delete Event on Watch recipe所以我已經超出了我的咕嘟咕嘟/ JS知識水平伴隨着這種實驗。
在此先感謝。