forked from ckan/ckan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
96 lines (81 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
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;
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-sass/assets/**/*").pipe(
dest(__dirname + "/ckan/public/base/vendor/bootstrap/")
);
const moment = () =>
src(__dirname + "/node_modules/moment/min/moment-with-locales.js").pipe(
dest(__dirname + "/ckan/public/base/vendor")
);
const fontAwesomeCss = () =>
src(__dirname + "/node_modules/font-awesome/css/font-awesome.css").pipe(
dest(__dirname + "/ckan/public/base/vendor/font-awesome/css")
);
const fontAwesomeFonts = () =>
src(__dirname + "/node_modules/font-awesome/fonts/*").pipe(
dest(__dirname + "/ckan/public/base/vendor/font-awesome/fonts")
);
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,
moment,
fontAwesomeCss,
fontAwesomeFonts,
jQueryFileUpload,
qs,
highlightJs,
highlightJsStyles
);