-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvite.config.ts
63 lines (62 loc) · 1.54 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
import { defineConfig } from "vite"
import vue from "@vitejs/plugin-vue"
import { spawnSync } from "child_process"
import * as fs from "fs"
import * as path from "path"
import lang from "./src/languages.json"
import packageJson from "./package.json"
import Components from "unplugin-vue-components/vite"
import { PrimeVueResolver } from "unplugin-vue-components/resolvers"
// this is a lot more work than it could be
const { status, stdout, stderr } = spawnSync("npm", ["list", "--json"], {
encoding: "utf8",
})
// this is a lot more work than it could be
// https://vitejs.dev/config/
export default defineConfig({
base: "/",
plugins: [
vue(),
Components({
resolvers: [PrimeVueResolver()],
}),
],
build: {
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes("node_modules")) {
if (id.includes("codemirror-lang-ic10")) {
return "codemirror-lang-ic10"
}
if (id.includes("ic10")) {
return "ic10"
}
const pkgName = (id.match(/node_modules\/([^/]+)/) ?? [])[1]
if (pkgName) return `vendor-${pkgName}`
return "vendor"
}
},
},
},
},
//@ts-ignore типы vite устарели
exclude: ["cypress/**"],
resolve: {
preserveSymlinks: true,
},
define: {
__languages__: fs.readdirSync(path.join(__dirname, "src/locales")),
__LanguageSelector__: lang.map((l) => {
return {
name: l.name,
code: l.code,
flag: l.ICON ?? "",
percentage: l.percentage,
}
}),
__package__: stdout,
__bugs__: packageJson.bugs ?? "",
__buildTime__: Date.now(),
},
})