generated from canopy-iiif/canopy-iiif
-
Notifications
You must be signed in to change notification settings - Fork 0
/
canopy.js
44 lines (37 loc) · 1001 Bytes
/
canopy.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
require("dotenv").config();
const aggregate = require("./services/build/aggregate");
const {
getConfig,
getOptions,
getNavigation,
} = require("./services/build/config");
const args = process.argv;
(() => {
const path = args
.find((value) => value.includes("--path="))
?.split("=")
?.pop();
const config = getConfig(path);
const options = getOptions();
const navigation = getNavigation();
const { prod, dev } = config;
config.environment = args.includes("dev") ? dev : prod;
config.options = options;
const url = args.includes("dev")
? `http://localhost:5001`
: process.env.NEXT_PUBLIC_URL;
const basePath = process.env.NEXT_PUBLIC_BASE_PATH;
const baseUrl = basePath ? `${url}${basePath}` : url;
const env = {
CANOPY_CONFIG: {
...config.environment,
navigation: navigation,
...config.options,
url,
basePath,
baseUrl,
},
};
aggregate.build(env.CANOPY_CONFIG);
})();
module.exports = { getConfig };