generated from canopy-iiif/canopy-iiif
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathcanopy.ts
39 lines (32 loc) · 1006 Bytes
/
canopy.ts
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
require("dotenv").config();
const buildConfig = require("./src/lib/build/config");
const aggregate = require("./src/lib/build/aggregate");
const args = process.argv;
(() => {
const path = args
.find((value) => value.includes("--path="))
?.split("=")
?.pop();
const config = buildConfig.getConfig(path);
const options = buildConfig.getOptions();
const navigation = buildConfig.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);
})();