-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
executable file
·132 lines (116 loc) · 2.73 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
/* eslint-disable */
const package = require("./package.json");
const cleanCSS = require("gulp-clean-css");
const concat = require("gulp-concat");
const del = require("del");
const eslint = require("gulp-eslint");
const gulp = require("gulp");
const gulpif = require("gulp-if");
const rename = require("gulp-rename");
const uglifyES = require("gulp-uglify-es").default;
const buildPath = "build/";
let watching = true;
const copyPaths = [{
"input": "src/index.html",
"output": ""
},
{
"input": "favicon/*.{png,ico}",
"output": "favicon/"
},
{
"input": ["favicon/favicon.ico", "favicon/browserconfig.xml", "favicon/manifest.json"],
"output": ""
},
{
"input": "src/images/**/*",
"output": "images/"
},
{
"input": "vendor/**/css/**/*.css",
"output": ""
},
{
"input": "vendor/**/images/**/*",
"output": ""
},
{
"input": "vendor/**/js/**/*.js",
"output": ""
},
{
"input": "vendor/**/webfonts/**/*.{eot,svg,ttf,woff,woff2}",
"output": ""
},
{
"input": "vendor/**/cmaps/**/*",
"output": ""
},
{
"input": "vendor/**/locale/**/*",
"output": ""
}
];
const jsPath = {
"input": [
"./src/js/prototype.js",
"./src/js/jui/jComponent.js",
"./src/js/jui/*.js",
"./src/js/utils.js",
"./src/js/header.js",
"./src/js/api.js",
"./src/js/config.js",
"./src/js/pages/*.js",
"./src/js/footer.js"
],
"output": "js/"
};
const clean = (done) => {
del.sync(buildPath);
done();
};
const _copy = (paths, done) => {
const path = paths.pop();
if (typeof path === "undefined")
return done();
gulp
.src(path.input)
.pipe(gulp.dest(buildPath + path.output))
.on("end", () => {
_copy(paths, done);
});
}
const copy = (done) => {
_copy([...copyPaths], done);
};
const script = () => gulp.src(jsPath.input)
.pipe(eslint({
"configFile": ".eslintrc"
}))
.pipe(eslint.format())
.pipe(gulpif(!watching, eslint.failAfterError()))
.pipe(concat("noobs.js"))
// pipe(gulpif(!watching, uglifyES()))
.pipe(gulp.dest(buildPath + jsPath.output));
const watch = (done) => {
copyPaths.forEach((path) => gulp.watch(path.input, copy));
gulp.watch(scssPath.watch, scss);
gulp.watch(jsPath.input, script);
return done();
};
const production = (done) => {
watching = false;
return done();
};
const development = (done) => {
watching = true;
return done();
};
exports.clean = gulp.series(clean);
exports.build = gulp.series(production, exports.clean, copy, script);
exports.watch = gulp.series(development, exports.clean, copy, script, watch);
exports.default = (done) => {
// eslint-disable-next-line no-console
console.log(`\n* * * Available tasks: ${Object.keys(exports)} * * *\n`);
return done();
};