-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
151 lines (137 loc) · 3.29 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
"use strict";
const gulp = require("gulp");
const rename = require("gulp-rename");
const eslint = require("gulp-eslint");
const gulpStylelint = require("gulp-stylelint");
const prettify = require("gulp-jsbeautifier");
const BASE_DIR = "./";
const JSFiles = [
"./**/*.js",
"!**/*.min.js",
"!**/vendor/**/*",
"!_site/**/*",
"!jukax-about/**/*",
"!meet-ubuntu-ads/**/*",
"!meet-ubuntu-ads_next/**/*",
"!tests/**/*",
"!jukax/**/*",
"!node_modules/**/*",
// "gulpfile.js",
];
const CSSFiles = [
"./**/*.css",
"./**/*.scss",
"./**/*.sass",
"./**/*.less",
"!_assets/css/*.scss",
"!**/*.min.css",
"!**/vendor/**/*",
"!_site/**/*",
"!jukax-about/**/*",
"!meet-ubuntu-ads/**/*",
"!meet-ubuntu-ads_next/**/*",
"!tests/**/*",
"!jukax/**/*",
"!node_modules/**/*",
];
const HTMLFiles = [
".**/*.html",
"!**/vendor/**/*",
"!_site/**/*",
"!jukax-about/**/*",
"!meet-ubuntu-ads/**/*",
"!meet-ubuntu-ads_next/**/*",
"!tests/**/*",
"!jukax/**/*",
"!node_modules/**/*",
];
const jsLint = () =>
gulp
.src(JSFiles)
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
const jsPrettify = () =>
gulp
.src(JSFiles.concat([".jsbeautifyrc", ".stylelintrc"]))
.pipe(
prettify({
js: {
file_types: [".js", ".json", ".jsbeautifyrc", ".stylelintrc"],
config: "./.jsbeautifyrc",
},
})
)
.pipe(gulp.dest((_) => _.base));
const cssLint = () =>
gulp.src(CSSFiles).pipe(
gulpStylelint({
reporters: [
{
formatter: "string",
console: true,
},
],
})
);
const cssPrettify = () =>
gulp
.src(CSSFiles)
.pipe(
prettify({
css: {
file_types: [".css", ".less", ".sass", ".scss"],
config: "./.jsbeautifyrc",
},
})
)
.pipe(gulp.dest((_) => _.base));
const htmlPrettify = () =>
gulp
.src(HTMLFiles)
.pipe(
prettify({
html: {
file_types: [".html"],
config: "./.jsbeautifyrc",
},
})
)
.pipe(gulp.dest((_) => _.base));
// Copy vendor files from /node_modules into /vendor
// NOTE: requires `npm install` before running!
const copy = gulp.parallel(
() =>
gulp
.src(["node_modules/font-awesome/css/*", "!**/*.map"])
.pipe(gulp.dest(BASE_DIR + "_assets/vendor/font-awesome/css")),
() =>
gulp
.src(["node_modules/font-awesome/fonts/*"])
.pipe(gulp.dest(BASE_DIR + "_assets/vendor/font-awesome/fonts")),
() =>
gulp
.src([
"node_modules/bootstrap/dist/**/bootstrap.*",
"node_modules/bootstrap/dist/**/bootstrap-*.*",
"!**/bootstrap-theme.*",
"!**/bootstrap.bundle.*",
"!**/*.map",
"!**/fonts/*",
])
.pipe(gulp.dest(BASE_DIR + "_assets/vendor/bootstrap")),
() =>
gulp
.src(["node_modules/normalize.css/normalize.css"])
.pipe(rename("normalize.scss"))
.pipe(gulp.dest(BASE_DIR + "_sass/vendor"))
);
const html = gulp.series(htmlPrettify);
const css = gulp.series(cssPrettify, cssLint);
const js = gulp.series(() => Promise.resolve(true) /*jsPrettify, jsLint*/);
// Default task
const defaultTask = gulp.series(html, js, css, copy);
exports.html = html;
exports.css = css;
exports.js = js;
exports.default = defaultTask;