-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.ts
77 lines (65 loc) · 1.8 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
66
67
68
69
70
71
72
73
74
75
76
77
import { defineConfig, LibraryOptions } from "vite";
import vue from "@vitejs/plugin-vue";
import { resolve } from "path";
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => ({
plugins: [
vue({
reactivityTransform: true,
template: {
compilerOptions: {
hoistStatic: true,
},
},
}),
// {
// // @todo report
// // for some reason sfc compiler exports vue macro for reactivity transform
// // fixed by referencing in env.d.ts
// name: "Fix reactivity transform",
// transform(code, id) {
// if (/\.vue/.test(id)) {
// return code.replace(/\$shallowRef,?/g, "");
// }
// },
// },
],
base: "/vue-smoothie/",
publicDir: mode === "lib" ? false : "public",
esbuild: {
drop: ["console"],
},
build: {
minify: mode === "lib" ? false : "esbuild",
sourcemap: mode !== "lib",
// minify: "terser",
// terserOptions: {
// mangle: true,
// compress: {
// drop_console: true,
// },
// },
outDir: mode === "lib" ? "dist_lib" : "dist",
emptyOutDir: !process.env.__OMNI,
rollupOptions: {
output: {
entryFileNames:
mode === "lib" ? (process.env.__OMNI ? "omniSmoothie.js" : "smoothie.js") : `[name].js`,
chunkFileNames: `[name].js`,
assetFileNames: `[name].[ext]`,
},
// make sure to externalize deps that shouldn't be bundled
// into your library
external: mode === "lib" ? ["vue", "three"] : undefined,
},
lib:
mode === "lib"
? ({
entry: resolve(__dirname, "index.js"),
name: "Smoothie Components Library",
formats: ["es"],
} as LibraryOptions)
: undefined,
},
envPrefix: ["VITE_", "__"],
}));