forked from tyrasd/overpass-turbo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
65 lines (61 loc) · 1.53 KB
/
vite.config.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
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
/// <reference types="vitest" />
import {defineConfig} from "vite";
import inject from "@rollup/plugin-inject";
import pegjs from "rollup-plugin-pegjs";
import {readFileSync} from "fs";
import {resolve} from "path";
import {execSync} from "child_process";
const GIT_VERSION = JSON.stringify(
execSync("git log -1 --format=%cd --date=short", {encoding: "utf-8"}).trim() +
"/" +
execSync("git describe --always", {encoding: "utf-8"}).trim()
);
const dependencies = JSON.parse(
readFileSync("package.json", {encoding: "utf-8"})
)["dependencies"];
const APP_DEPENDENCIES = JSON.stringify(
Object.keys(dependencies)
.map((dependency) =>
JSON.parse(
readFileSync(`node_modules/${dependency}/package.json`, {
encoding: "utf8"
})
)
)
.map(
({name, version, license}) =>
`<a href="https://www.npmjs.com/package/${name}/v/${version}">${name}</a> ${version} (${license})`
)
.join(", ")
);
// https://vitejs.dev/config/
export default defineConfig(() => {
return {
base: "./",
build: {
rollupOptions: {
input: [
resolve(__dirname, "index.html"),
resolve(__dirname, "land.html"),
resolve(__dirname, "map.html")
]
}
},
define: {
APP_DEPENDENCIES,
GIT_VERSION
},
plugins: [
inject({
$: "jquery",
jQuery: "jquery"
}),
pegjs()
],
// https://vitest.dev/config/
test: {
environment: "happy-dom",
include: "tests/test*.js"
}
};
});