forked from openfoodfacts/openfoodfacts-server
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
137 lines (126 loc) · 4.13 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
/*global exports */
const { src, dest, series, parallel } = require("gulp");
const concat = require("gulp-concat");
const sass = require("gulp-sass");
const sourcemaps = require("gulp-sourcemaps");
const minifyCSS = require("gulp-csso");
const terser = require("gulp-terser-js");
const svgmin = require("gulp-svgmin");
const sassOptions = {
errLogToConsole: true,
outputStyle: "expanded",
includePaths: ["./node_modules/foundation-sites/scss"]
};
function icons() {
return src("*.svg", { cwd: "./icons" }).
pipe(
svgmin({
plugins: [
{ removeMetadata: false },
{ removeTitle: false },
{ removeDimensions: true },
{ addClassesToSVGElement: { className: "icon" } },
{
addAttributesToSVGElement: {
attributes: [{ "aria-hidden": "true", focusable: "false" }]
}
}
]
})
).
pipe(dest("./html/images/icons/dist"));
}
function css() {
return src("./scss/**/*.scss").
pipe(sourcemaps.init()).
pipe(sass(sassOptions).on("error", sass.logError)).
pipe(minifyCSS()).
pipe(sourcemaps.write(".")).
pipe(dest("./html/css/dist"));
}
function copyJs() {
return src(
[
"./node_modules/@webcomponents/**/webcomponentsjs/**/*.js",
"./node_modules/foundation-sites/js/vendor/*.js",
"./node_modules/foundation-sites/js/foundation.js",
"./node_modules/papaparse/papaparse.js",
"./node_modules/osmtogeojson/osmtogeojson.js",
"./node_modules/leaflet/dist/leaflet.js",
"./node_modules/leaflet.markercluster/dist/leaflet.markercluster.js",
"./node_modules/blueimp-tmpl/js/tmpl.js",
"./node_modules/blueimp-load-image/js/load-image.all.min.js",
"./node_modules/blueimp-canvas-to-blob/js/canvas-to-blob.js",
"./node_modules/blueimp-file-upload/js/*.js",
"./node_modules/@yaireo/tagify/dist/tagify.min.js",
"./node_modules/cropper/dist/cropper.js"
]).
pipe(sourcemaps.init()).
pipe(terser()).
pipe(sourcemaps.write(".")).
pipe(dest("./html/js/dist"));
}
function buildJs() {
return src([
'./html/js/display*.js',
'./html/js/product-multilingual.js',
'./html/js/search.js'
]).
pipe(sourcemaps.init()).
pipe(terser()).
pipe(sourcemaps.write(".")).
pipe(dest("./html/js/dist"));
}
function buildjQueryUi() {
return src([
'./node_modules/jquery-ui/ui/version.js',
'./node_modules/jquery-ui/ui/widget.js',
'./node_modules/jquery-ui/ui/position.js',
'./node_modules/jquery-ui/ui/keycode.js',
'./node_modules/jquery-ui/ui/unique-id.js',
'./node_modules/jquery-ui/ui/safe-active-element.js',
'./node_modules/jquery-ui/ui/widgets/autocomplete.js',
'./node_modules/jquery-ui/ui/widgets/menu.js'
]).
pipe(sourcemaps.init()).
pipe(terser()).
pipe(concat('jquery-ui.js')).
pipe(sourcemaps.write(".")).
pipe(dest('./html/js/dist'));
}
function jQueryUiThemes() {
return src([
'./node_modules/jquery-ui/themes/base/core.css',
'./node_modules/jquery-ui/themes/base/autocomplete.css',
'./node_modules/jquery-ui/themes/base/menu.css',
'./node_modules/jquery-ui/themes/base/theme.css',
]).
pipe(sourcemaps.init()).
pipe(minifyCSS()).
pipe(concat('jquery-ui.css')).
pipe(sourcemaps.write(".")).
pipe(dest('./html/css/dist/jqueryui/themes/base'));
}
function copyCss() {
return src([
"./node_modules/leaflet/dist/leaflet.css",
"./node_modules/leaflet.markercluster/dist/MarkerCluster.css",
"./node_modules/leaflet.markercluster/dist/MarkerCluster.Default.css",
"./node_modules/@yaireo/tagify/dist/tagify.css",
"./html/css/product-multilingual.css",
"./node_modules/cropper/dist/cropper.css"
]).
pipe(sourcemaps.init()).
pipe(minifyCSS()).
pipe(sourcemaps.write(".")).
pipe(dest("./html/css/dist"));
}
function copyImages() {
return src(["./node_modules/leaflet/dist/**/*.png"]).
pipe(dest("./html/css/dist"));
}
exports.copyJs = copyJs;
exports.buildJs = buildJs;
exports.css = css;
exports.icons = icons;
exports.default = parallel(copyJs, buildJs, buildjQueryUi, copyCss, copyImages, jQueryUiThemes, series(icons, css));