forked from gasparesganga/jquery-loading-overlay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
92 lines (80 loc) · 2.35 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
"use strict";
var fs = require("fs");
var pkg = require("./package.json");
var headerTemplate = fs.readFileSync("header.txt");
var headerVars = {
name : "LoadingOverlay",
author : "Gaspare Sganga",
description : pkg.description,
version : pkg.version,
license : pkg.license,
documentation : pkg.homepage
};
var paths = {
src : "src/",
dest : "dist/"
}
var gulp = require("gulp");
var del = require("del");
var inquirer = require("inquirer");
var rename = require("gulp-rename");
var replace = require("gulp-replace");
var header = require("gulp-header");
var sourcemaps = require("gulp-sourcemaps");
var uglify = require("gulp-uglify");
function src_headers(){
return gulp.src([paths.src + "*.js", paths.src + "*.css"])
.pipe(replace(/^\/\*{99}[^*]+\*{99}\/(\r\n|\r|\n)/, ""))
.pipe(header(headerTemplate, headerVars))
.pipe(gulp.dest(paths.src));
}
function dist_clean(){
return del([paths.dest + "*"]);
}
function dist_js(){
return gulp.src(paths.src + "*.js")
.pipe(gulp.dest(paths.dest))
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(header(headerTemplate, headerVars))
.pipe(rename({
extname : ".min.js"
}))
.pipe(sourcemaps.write("./", {
addComment : false
}))
.pipe(gulp.dest(paths.dest));
}
gulp.task("default", function(){
return inquirer.prompt([{
type : "list",
name : "task",
message : "Select the task to run",
choices : [
{
name : "Update source headers",
value : "src"
},
{
name : "Update dist",
value : "dist"
},
{
name : "Exit",
value : "exit"
}
],
pageSize : "3"
}]).then(function(ret){
switch (ret.task) {
case "src":
gulp.parallel(src_headers)();
break;
case "dist":
gulp.series(dist_clean, dist_js)();
break;
default:
console.log("\nNothing done\n");
}
});
});