1.1.0 • Published 2 years ago

mill-gulp-utils v1.1.0

Weekly downloads
2
License
ISC
Repository
github
Last release
2 years ago

mill-gulp-utils

关于gulp的一些工具封装

轻量级的自定义插件

var mplug=require("mill-gulp-utils").mplug;
var gulp=require("gulp");
var gutil=require("gulp-util");
module.exports=function  () {
	gulp.src('test/**/*.js')
	.pipe(mplug(function  (gutil,file,enc,content) {
		//自定义插件
		gutil.log(gutil.colors.red(file.path));
		gutil.log(content);
		return content;//需要返回content
	})).pipe(gulp.dest("dist"));
}

独立的自定义插件

var tpl=require("mill-gulp-utils").tpl;
module.exports=tpl({
  PLUGIN_NAME:'t2',
  argsTrue:function (arguments) {
    return arguments.length>=1;
  },
  doPlagin:function  (gutil,file,enc,content) {
    gutil.log(content);
    return content;
  }
});

新版的gulp插件

export default GulpTemplate((code, file) => {
    const ast = parse(code, parseOption)
    traverse(ast, {
        enter(path) {
            delete path.node.loc
            delete path.node.start
            delete path.node.end
            delete path.node.directives
        }
    })
    return stringify(ast.program)
})