-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
114 lines (97 loc) · 3.2 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 gulp = require('gulp');
const { series, parallel } = require('gulp');
const del = require('del');
const concat = require('gulp-concat');
const uglify = require('gulp-uglify');
const merge = require('merge-stream');
const replace = require('gulp-replace');
const cleancss = require('gulp-clean-css');
const plugin = {
'public': './webroot'
}
const main_styles = [
'./node_modules/leaflet/dist/leaflet.css',
'./node_modules/leaflet.fullscreen/Control.FullScreen.css',
'./node_modules/leaflet-gesture-handling/dist/leaflet-gesture-handling.css',
'./node_modules/leaflet.markercluster/dist/MarkerCluster.css',
'./node_modules/leaflet.markercluster/dist/MarkerCluster.Default.css',
'./node_modules/leaflet-control-geocoder/dist/Control.Geocoder.css',
'./node_modules/leaflet-legend/leaflet-legend.css'
];
const main_scripts = [
'./node_modules/leaflet/dist/leaflet.js',
'./node_modules/leaflet.fullscreen/Control.FullScreen.js',
'./node_modules/leaflet-gesture-handling/dist/leaflet-gesture-handling.min.js',
'./node_modules/leaflet.markercluster/dist/leaflet.markercluster.js',
'./node_modules/leaflet-control-geocoder/dist/Control.Geocoder.js',
'./node_modules/leaflet-legend/leaflet-legend.js'
];
const main_assets = [
{
'src': './node_modules/leaflet/dist/images/*',
'dest': '/images/'
},
{
'src': './node_modules/leaflet.locatecontrol/*.svg',
'dest': '/images/'
},
{
'src': './node_modules/leaflet.fullscreen/*.svg',
'dest': '/images/'
}
];
function clean(cb) {
assets = [
plugin.public + '/**',
'!' + plugin.public,
'!' + plugin.public + '/galette_maps.css',
plugin.public + '/images/**',
'!' + plugin.public + '/images',
'!' + plugin.public + '/images/marker-galette.png',
'!' + plugin.public + '/images/marker-galette-pro.png',
];
return del(assets, cb);
};
function styles() {
main = gulp.src(main_styles)
.pipe(replace('icon-fullscreen.svg', './images/icon-fullscreen.svg'))
.pipe(cleancss())
.pipe(concat('maps-main.bundle.min.css'))
.pipe(gulp.dest(plugin.public));
locate = gulp.src([
'./node_modules/leaflet.locatecontrol/dist/L.Control.Locate.min.css'
])
.pipe(replace('../location-arrow-solid.svg', './images/location-arrow-solid.svg'))
.pipe(replace('../spinner-solid.svg', './images/spinner-solid.svg'))
.pipe(cleancss())
.pipe(concat('maps-locate.bundle.min.css'))
.pipe(gulp.dest(plugin.public));
return merge(main, locate);
};
function scripts() {
main = gulp.src(main_scripts)
.pipe(concat('maps-main.bundle.min.js'))
.pipe(uglify())
.pipe(gulp.dest(plugin.public));
locate = gulp.src([
'./node_modules/leaflet.locatecontrol/dist/L.Control.Locate.min.js'
])
.pipe(concat('maps-locate.bundle.min.js'))
.pipe(uglify())
.pipe(gulp.dest(plugin.public));
return merge(main, locate);
};
function assets() {
main = main_assets.map(function (asset) {
return gulp.src(asset.src)
.pipe(gulp.dest(plugin.public + asset.dest));
}
);
return merge(main);
};
exports.clean = clean;
exports.styles = styles;
exports.scripts = scripts;
exports.assets = assets;
exports.build = series(styles, scripts, assets);
exports.default = exports.build;