forked from mdbootstrap/TW-Elements-React
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
50 lines (46 loc) · 1.25 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
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import path from "path";
import dts from "vite-plugin-dts";
import { externalizeDeps } from "vite-plugin-externalize-deps";
const entryPath = `src/lib/index.tsx`;
const packageName = "tw-elements-react";
const outDir = process.env.mode === "docs" ? "dist-docs" : "dist";
const libPlugins = [
react(),
dts({
copyDtsFiles: false,
entryRoot: entryPath,
outputDir: `./${outDir}/types/dts`,
}),
externalizeDeps(),
];
const docsPlugins = [react()];
// https://vitejs.dev/config/
export default defineConfig({
define: {
// for popper to not crash in docs
"process.env": {},
initiatedComponents: [],
},
plugins: process.env.mode === "docs" ? docsPlugins : libPlugins,
resolve: {
alias: {
"tw-elements-react": path.resolve("./src/lib/index.tsx"),
},
},
build: {
outDir: outDir,
emptyOutDir: process.env.buildFile ? false : true,
cssCodeSplit: true,
copyPublicDir: false,
lib: process.env.mode !== "docs" && {
entry: path.resolve(__dirname, entryPath),
name: "te",
formats: ["es", "umd"],
fileName: (format) => `js/${packageName}.${format}.min.js`,
},
sourcemap: true,
rollupOptions: {},
},
});