🏠 首页 › 日志 › 正文 gulp: 常用代码片段 - cheatsheet 常用代码片段 🕐 2025-05-20 22:42:42 常用功能名称备注代码clean清理 dist// "del": "^8.0.0" import { deleteAsync } from "del"; import gulp from "gulp"; gulp.task("clean", () => { return deleteAsync(["dist"]); }); gulp.task("default", gulp.series("clean"));shell执行 shell 命令import gulp from "gulp"; import readPkg from "@jswork/read-pkg-json"; import { exec } from "child_process"; gulp.task("compress", () => { const pkg = readPkg(); const distName = `${pkg.name}-${pkg.version}.tar.gz`; return exec(`cd dist && tar -czf ${distName} *`); }); gulp.task("default", gulp.series("compress"));shell pluginshell 插件const gulp = require('gulp') const shell = require('gulp-shell') gulp.task('example', () => { return gulp .src('*.js', { read: false }) .pipe(shell(['echo <%= file.path %>'])) })