-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
56 lines (49 loc) · 1.17 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
import { resolve } from "node:path";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
import dts from "vite-plugin-dts";
import packageData from "./package.json";
type BuildEnvironment = "storybook" | "library";
const buildEnvironment: BuildEnvironment =
(process.env.BUILD_ENV as BuildEnvironment) || "library";
const libPlugins = [
react(),
dts({
rollupTypes: true,
}),
];
const storybookPlugins = [
react({
jsxRuntime: "automatic",
}),
];
// https://vitejs.dev/config/
export default defineConfig({
plugins: buildEnvironment === "storybook" ? storybookPlugins : libPlugins,
build: {
lib: {
entry: resolve(__dirname, "src", "lib.ts"),
formats: ["es"],
fileName: (format) => `index.${format}.js`,
},
rollupOptions: {
external:
buildEnvironment === "storybook"
? []
: [...Object.keys(packageData.peerDependencies)],
output: {
// Since we publish our ./src folder, there's no point
// in bloating sourcemaps with another copy of it.
sourcemapExcludeSources: true,
},
},
target: "esnext",
sourcemap: true,
minify: false,
},
resolve: {
alias: {
"@": resolve(__dirname, "./src"),
},
},
});