-
Notifications
You must be signed in to change notification settings - Fork 60
/
vite.config.ts
52 lines (48 loc) · 1.24 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
// vite.config.js
import { resolve } from "path";
import { defineConfig } from "vite";
import { fileURLToPath, URL } from "url";
import vue from "@vitejs/plugin-vue";
import cssInjectedByJsPlugin from "vite-plugin-css-injected-by-js";
export default defineConfig({
root: "./playground",
plugins: [
vue(),
cssInjectedByJsPlugin({
jsAssetsFilterFunction: ({ fileName }) => fileName == "index.mjs" || fileName == "index.cjs",
}),
],
build: {
lib: {
entry: {
main: resolve(__dirname, "src/index.ts"),
themes: resolve(__dirname, "src/themes/index.ts"),
},
fileName: (format, entryName) => {
const formatExtensionMap = {
es: "mjs",
cjs: "cjs",
umd: "umd.js",
};
const ext = formatExtensionMap[format];
if (entryName === "themes") {
return `themes/index.${ext}`;
}
return `index.${ext}`;
},
},
rollupOptions: {
// make sure to externalize deps that shouldn't be bundled
// into your library
external: ["vue"],
output: {
dir: resolve(__dirname, "dist"),
},
},
},
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
},
},
});