forked from ckan/ckan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
114 lines (96 loc) · 3.32 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
const path = require("path");
const { src, watch, dest, parallel } = require("gulp");
const sass = require("gulp-sass")(require("sass"));
const if_ = require("gulp-if");
const sourcemaps = require("gulp-sourcemaps");
const rename = require("gulp-rename");
const with_sourcemaps = () => !!process.env.DEBUG || !!process.argv[4];
const renamer = (path) => {
const variant = process.argv[3];
if (variant) {
// convert main/main-rtl into green/green-rtl
path.basename = path.basename.replace("main", variant.slice(2));
}
return path;
};
const build = () =>
src([
__dirname + "/ckan/public/base/scss/main.scss",
__dirname + "/ckan/public/base/scss/main-rtl.scss",
])
.pipe(if_(with_sourcemaps(), sourcemaps.init()))
.pipe(sass({ outputStyle: 'expanded' }).on('error', sass.logError))
.pipe(if_(with_sourcemaps(), sourcemaps.write()))
.pipe(rename(renamer))
.pipe(dest(__dirname + "/ckan/public/base/css/"));
const watchSource = () =>
watch(
__dirname + "/ckan/public/base/scss/**/*.scss",
{ ignoreInitial: false },
build
);
const jquery = () =>
src(__dirname + "/node_modules/jquery/dist/jquery.js").pipe(
dest(__dirname + "/ckan/public/base/vendor")
);
const bootstrapScss = () =>
src([__dirname + "/node_modules/bootstrap/scss/**/*", ]).pipe(
dest(__dirname + "/ckan/public/base/vendor/bootstrap/scss")
);
const bootstrapJS = () =>
src([__dirname + "/node_modules/bootstrap/js/dist/**/*",
__dirname + "/node_modules/bootstrap/dist/js/**/*"
]).pipe(dest(__dirname + "/ckan/public/base/vendor/bootstrap/js"));
const moment = () =>
src(__dirname + "/node_modules/moment/min/moment-with-locales.js").pipe(
dest(__dirname + "/ckan/public/base/vendor")
);
const popOver = () =>
src(__dirname + "/node_modules/@popperjs/core/dist/cjs/popper.js").pipe(
dest(__dirname + "/ckan/public/base/vendor/")
);
const DOMPurify = () =>
src(__dirname + "/node_modules/dompurify/dist/purify.js").pipe(
dest(__dirname + "/ckan/public/base/vendor/")
);
const fontAwesomeCss = () =>
src(__dirname + "/node_modules/@fortawesome/fontawesome-free/css/all.css").pipe(
dest(__dirname + "/ckan/public/base/vendor/fontawesome-free/css")
);
const fontAwesomeFonts = () =>
src(__dirname + "/node_modules/@fortawesome/fontawesome-free/webfonts/*").pipe(
dest(__dirname + "/ckan/public/base/vendor/fontawesome-free/webfonts")
);
const jQueryFileUpload = () =>
src(__dirname + "/node_modules/blueimp-file-upload/js/*.js").pipe(
dest(__dirname + "/ckan/public/base/vendor/jquery-fileupload/")
);
const qs = () =>
src(__dirname + "/node_modules/qs/dist/qs.js").pipe(
dest(__dirname + "/ckan/public/base/vendor/")
)
const highlightJs = () =>
src(__dirname + "/node_modules/@highlightjs/cdn-assets/highlight.js").pipe(
dest(__dirname + "/ckanext/textview/theme/public/vendor/")
)
const highlightJsStyles = () =>
src(__dirname + "/node_modules/@highlightjs/cdn-assets/styles/a11y-light.min.css").pipe(
rename("a11y-light.css")).pipe(
dest(__dirname + "/ckanext/textview/theme/public/styles/")
)
exports.build = build;
exports.watch = watchSource;
exports.updateVendorLibs = parallel(
jquery,
bootstrapScss,
bootstrapJS,
moment,
fontAwesomeCss,
fontAwesomeFonts,
jQueryFileUpload,
qs,
DOMPurify,
popOver,
highlightJs,
highlightJsStyles
);