UNPKG

pkgdev

Version:
1 lines 1.82 kB
var fs=require("fs"),gulp=require("gulp"),plugins=require("gulp-load-plugins")(),config=require("./package.json"),browserSync=require("browser-sync"),reload=browserSync.reload,sass=require("gulp-sass"),group=require("./gulp-group"),path={js:config.jsfile||["src/js/*.js"],css:config.cssfile||["src/style/*.css","src/style/*.scss"],gulp:["./gulpfile.source.js","./gulp-group.source.js"]};gulp.task("server",function(){browserSync.init({port:config.port||16898,server:{baseDir:"./"}}),gulp.watch(["index.js","demo/**/*"],{cwd:"./"},reload)}),gulp.task("demo",function(){return gulp.src(["demo/main.js"]).pipe(group.file()).pipe(gulp.dest("./demo/"))}),gulp.task("cssindex",function(){return gulp.src(path.css).pipe(plugins.concat("widget.scss")).pipe(group.wrap()).pipe(sass({outputStyle:"compressed"}).on("error",sass.logError)).pipe(gulp.dest("./src/")).pipe(plugins.notify({message:"CSS task complete"}))}),gulp.task("jsindex",["cssindex"],function(){return gulp.src(path.js).pipe(group.file()).pipe(plugins.concat("index.js")).pipe(gulp.dest("./")).pipe(group.clean()).pipe(plugins.uglify()).pipe(plugins.rename({extname:".min.js"})).pipe(gulp.dest("./")).pipe(plugins.notify({message:"JS task complete"}))}),gulp.task("build",function(){return gulp.src(["./index.js","./index.min.js"]).pipe(plugins.copy("./"+config.version,{prefix:0}))}),gulp.task("jsmin",function(){return gulp.src(path.gulp).pipe(plugins.uglify()).pipe(plugins.rename(function(a){a.basename=a.basename.replace(/\.source/,"@")})).pipe(gulp.dest("./"))}),gulp.task("watch",function(){gulp.watch(path.js,["jsindex"]),gulp.watch("src/*.tpl",["jsindex"]),gulp.watch(path.css,["jsindex"]),gulp.watch(path.gulp,["jsmin"])}),gulp.task("file",["cssindex","jsindex","demo"]),gulp.task("sync",["watch","server"]),gulp.task("default",["file","watch","server"]);