-
Notifications
You must be signed in to change notification settings - Fork 6
/
gulpfile.js
179 lines (161 loc) · 5.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/*
* Copyright (C) 2024 con terra GmbH ([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const gulp = require("gulp");
const mapapps = require('ct-mapapps-gulp-js');
const mapappsBrowserSync = require("ct-mapapps-browser-sync");
const isProduction = process.env.NODE_ENV === "production";
console.info(`Configuring gulp build for ${isProduction ? "production" : "development"}`);
const localOverrides = (function () {
if (isProduction) {
// Never override defaults in production mode
return undefined;
}
try {
return require("./gulpfile.overrides");
} catch (e) {
// File may not exist
return undefined;
}
})();
// used to transport test urls in "run-browser-tests-local" task
const runBrowserTests = [];
mapapps.registerTasks({
/** Enable debug logging */
debug: localOverrides?.debug ?? false,
/** enable linting */
lintOnWatch: localOverrides?.lintOnWatch ?? true,
/** enable es6 by default */
forceTranspile: true,
/* A detailed description of available setting is available at https://www.npmjs.com/package/ct-mapapps-gulp-js */
compress: isProduction,
/* build source maps as e.g. ".js.map" */
sourceMaps: "file",
/** Build Unit-Tests only in dev mode */
rollupBuildTests: !isProduction,
/** Amount of Threads used to build the bundles, if there are only a few bundles 1 is ok.
* More as 3 is normally not required.
*/
rollupBuildMaxWorkers: localOverrides?.rollupBuildMaxWorkers ?? 1,
/** List of build time flags, usage like: import { debug } from "build-config!".
*/
rollupConfig: {
debug: !isProduction
},
/* a list of themes inside this project */
themes: [],
/* state that the custom theme will be dependant from map.apps everlasting theme that provides the base styles */
hasBaseThemes: true,
/* state that we want to support vuetify components and therefore need the vuetify core styles*/
hasVuetify: true,
themeChangeTargets: {
"vuetify": []
},
/* A list oft target browser versions. This should be streamlined with Esri JS API requirements. */
transpileTargets: {
firefox: 102,
edge: 104,
chrome: 104,
safari: 15
},
runBrowserTests,
watchFinishedReceiver() {
if (localOverrides?.autoReload ?? true) {
mapappsBrowserSync.state.reload();
}
}
}, gulp);
mapappsBrowserSync.registerTask({
// on which port to listen
port: localOverrides?.port ?? 9090,
// activate https protocol, generates a self signed certificate for "localhost"
// https://browsersync.io/docs/options#option-https
https: localOverrides?.https ?? false,
// to prevent auto open of browser, set this to false
urlToOpen: localOverrides?.openBrowser ?? true,
properties: {
paths: [
// Ensure @@key@@ expressions filtered in tests files
/^\/js\/tests\/(runTests.html|test-init.js|init-packs.js)$/
]
},
jsreg: {
//npmDir : __dirname + "/node_modules/",
npmModules: [
"mocha",
"chai",
"@conterra/mapapps-mocha-runner"
]
},
// prevent reload by browser sync (reload triggered on watch end)
externalReloadTrigger: true
}, gulp);
gulp.task("build",
gulp.series(
"copy-resources",
"themes-copy",
gulp.parallel(
"js-transpile",
"rollup-build",
"themes-compile"
)
)
);
gulp.task("lint",
gulp.parallel(
"js-lint"
/*, comment in to lint .css/.less files
"style-lint"
*/
));
gulp.task("preview",
gulp.series(
"build",
gulp.parallel(
"watch",
"browser-sync"
)
));
gulp.task("run-tests",
gulp.series(
"browser-sync-start",
function transportTestUrls() {
// transport test url to run-browser-tests
// eslint-disable-next-line max-len
const testsAt = mapappsBrowserSync.state.url + "/resources/jsregistry/root/@conterra/mapapps-mocha-runner/latest/mocha.html?boot=/js/tests/test-init.js&timeout=5000&test=dn_querybuilder/tests/all&reporter=tap";
runBrowserTests.push(testsAt);
return Promise.resolve();
},
"run-browser-tests",
"browser-sync-stop"
));
gulp.task("test",
gulp.series(
"build",
"lint",
"run-tests"
));
gulp.task("compress",
gulp.series(
"build",
"themes-compress",
"lint"
)
);
gulp.task("default",
gulp.series(
"build",
"lint"
));