-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvite.config.ts
More file actions
94 lines (91 loc) · 2.37 KB
/
vite.config.ts
File metadata and controls
94 lines (91 loc) · 2.37 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/// <reference types="vitest" />
import { defineConfig } from "vite";
import dts from "vite-plugin-dts";
import { resolve } from "path";
import { readFileSync } from "fs";
const packageJson = JSON.parse(readFileSync("./package.json", "utf-8"));
const isPackageBuild = process.env.BUILD_MODE === "package";
export default defineConfig({
base: "./",
build: isPackageBuild ? {
lib: {
entry: resolve(__dirname, "src/index.ts"),
formats: ["es", "umd"],
name: "Maplat",
fileName: (format) => {
switch (format) {
case "es":
return "maplat_core.js";
case "cjs":
return "maplat_core.cjs";
case "umd":
return "maplat_core.umd.js";
default:
return "maplat_core.js";
}
}
},
rollupOptions: {
external: ["ol", "ol/proj", "ol/source", "ol/layer", "ol/Map", "ol/View", "ol/Feature", "ol/geom/Point", "ol/style"],
output: {
globals: {
ol: "ol",
"ol/proj": "ol.proj",
"ol/source": "ol.source",
"ol/layer": "ol.layer",
"ol/Map": "ol.Map",
"ol/View": "ol.View",
"ol/Feature": "ol.Feature",
"ol/geom/Point": "ol.geom.Point",
"ol/style": "ol.style"
},
assetFileNames: (assetInfo) => {
if (assetInfo.name === "style.css") {
return "maplat_core.css";
}
// Vite 6.x uses "core.css" instead of "style.css"
if (assetInfo.name === "core.css") {
return "maplat_core.css";
}
return assetInfo.name || "asset-[name].[ext]";
},
inlineDynamicImports: true
}
},
sourcemap: true,
copyPublicDir: false
} : {
outDir: "dist-demo",
emptyOutDir: true
},
plugins: [
dts({
outDir: "dist",
exclude: ["spec", "node_modules"],
rollupTypes: false,
tsconfigPath: "./tsconfig.json",
logLevel: "silent",
insertTypesEntry: true,
staticImport: true
})
],
test: {
environment: "jsdom",
globals: true,
setupFiles: ["./spec/setup.ts"]
},
resolve: {
alias: {
"@": resolve(__dirname, "./src")
}
},
define: {
"import.meta.env.APP_VERSION": JSON.stringify(packageJson.version),
global: "globalThis"
},
server: {
host: "0.0.0.0",
port: 5175,
open: false
}
});