-
Notifications
You must be signed in to change notification settings - Fork 0
/
svelte.config.js
52 lines (49 loc) · 1.41 KB
/
svelte.config.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
import adapter from "@sveltejs/adapter-static";
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
import { readFileSync } from "fs";
function getConfig() {
if (!(process.env["npm_lifecycle_script"]?.startsWith("vite") ?? false)) {
return {};
}
const location = process.env.VITE_CONFIG;
if (location === undefined || location === "undefined") {
throw new Error("No config specified");
}
return JSON.parse(readFileSync(location, "utf8"));
}
const config = getConfig();
const basePath =
config["admin-uri"] !== undefined
? new URL(config["admin-uri"]).pathname
: "";
export default {
kit: {
adapter: adapter({
assets: "dist",
fallback: "index.html",
pages: "dist",
precompress: false,
strict: true,
}),
csp: {
/* eslint-disable @typescript-eslint/naming-convention -- These are CSP directive names */
directives: {
"default-src": ["self"],
"font-src": ["self", "data:"],
"img-src": ["self", "data:"],
"object-src": ["none"],
"style-src": ["self", "unsafe-inline"],
"upgrade-insecure-requests": true,
...(config["csp-report-uri"] !== undefined && {
"report-uri": [config["csp-report-uri"]],
}),
},
/* eslint-enable @typescript-eslint/naming-convention */
mode: "hash",
},
paths: {
base: basePath,
},
},
preprocess: vitePreprocess(),
};