-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
159 lines (132 loc) · 4.24 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
const gulp = require('gulp');
// Uglify
// const uglify = require('gulp-uglify'); // https://www.npmjs.com/package/gulp-uglify
const terser = require('gulp-terser'); // Supports ES5 and ES6
const concat = require('gulp-concat');
const inject = require('gulp-inject-string'); // Prepends string to top of builds
// const plumber = require("gulp-plumber"); // Pipe sequence
// const rename = require("gulp-rename");
// const sass = require("gulp-sass");
const pump = require('pump');
const fs = require('fs')
const json = JSON.parse(fs.readFileSync('package.json', 'utf8'))
const version = json.version;
function log(arg) {
console.log(arg);
}
var msg = "// AFTC.JS Version " + version + "\n"
msg += "// Author: [email protected]" + "\n";
// The core, the base, the essentials, the foundations, the stuff I can't live without
var aftc_core = [
"./src/aftc.js",
"./src/core/events.js",
"./src/core/random.js",
"./src/core/io.js",
"./src/core/cookies.js",
// "./src/core/debug.js",
// "./src/core/array.js",
// "./src/core/get.js",
// "./src/core/is.js",
// "./src/core/random.js",
// "./src/core/string.js",
// "./src/core/conversion.js",
// "./src/core/datetime.js",
// "./src/core/validation.js",
// "./src/core/detection.js",
// "./src/core/dom.js",
// "./src/core/css.js",
// "./src/core/browser.js",
// "./src/core/cookies.js",
// "./src/core/form.js",
// "./src/core/geometry.js",
// "./src/core/video.js",
// "./src/core/misc.js"
];
// The extras, the modules, the ooo or to some, the bloat
// Nice to have, but not essential
var aftc_modules = [
// The AFTC Core (required) START
"./src/aftc.js",
"./src/core/debug.js",
"./src/core/events.js",
"./src/core/events-extended.js",
"./src/core/io.js",
"./src/core/array.js",
"./src/core/get.js",
"./src/core/is.js",
"./src/core/random.js",
"./src/core/random-extended.js",
"./src/core/string.js",
"./src/core/conversion.js",
"./src/core/datetime.js",
"./src/core/validation.js",
"./src/core/detection.js",
"./src/core/dom.js",
"./src/core/css.js",
"./src/core/browser.js",
"./src/core/cookies.js",
"./src/core/form.js",
"./src/core/geometry.js",
"./src/core/video.js",
"./src/core/misc.js",
// The AFTC Core (required) END
"./src/AFTC/AFTC.Audio.js", // Enables new AFTC.Audio() and playSound()
"./src/AFTC/AFTC.Animate.js", // Enables new AFTC.Animate()
// "./src/AFTC/AFTC.Canvas.js", // Enables new AFTC.Canvas(); (WORK IN PROGRESS);
// "./src/AFTC/AFTC.CheckboxHideShow.js", // Up for review - to be updated or removed
"./src/AFTC/AFTC.Color.js", // Enables new AFTC.Color();
"./src/AFTC/AFTC.Visibility.js", // Enables hide(), show(), fade(), fadeIn() & fadeOut()
// "./src/AFTC/AFTC.ResizeManager.js", // Up for review - to be updated or removed
"./src/AFTC/AFTC.XHR.js", // Everyone needs some IO, I know I do...
];
const allFiles = aftc_core.concat(aftc_modules);
function buildCore(done) {
gulp.src(aftc_core)
.pipe(concat('aftc.core.js'))
.pipe(inject.prepend(msg))
.on("error", function (e) {
console.log(e.toString());
this.emit("end");
})
.pipe(gulp.dest('./dist/'));
done();
}
function buildCoreMin(done) {
pump([
gulp.src(aftc_core),
concat('aftc.core.min.js'),
terser(),
inject.prepend(msg),
gulp.dest('./dist/')
],
done
);
}
function buildDev(done) {
gulp.src(aftc_modules)
.pipe(concat('aftc.js'))
.pipe(inject.prepend(msg))
.on("error", function (e) {
console.log(e.toString());
this.emit("end");
})
.pipe(gulp.dest('./dist/'));
done();
}
function buildDist(done) {
pump([
gulp.src(aftc_modules),
concat('aftc.min.js'),
terser(),
inject.prepend(msg),
gulp.dest('./dist/')
],
done
);
}
gulp.task("build", gulp.parallel(buildCore, buildCoreMin, buildDev, buildDist));
gulp.task("watch", function(){
gulp.watch([
"./src/**/*.js"
], gulp.parallel(buildCore, buildCoreMin, buildDev, buildDist));
});