-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathvite.config.mts
More file actions
47 lines (45 loc) · 1.35 KB
/
vite.config.mts
File metadata and controls
47 lines (45 loc) · 1.35 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
import { codecovVitePlugin } from "@codecov/vite-plugin";
import react from "@vitejs/plugin-react";
import { resolve } from "path";
import { LibraryFormats, defineConfig, loadEnv } from "vite";
import dts from "vite-plugin-dts";
import noBundlePlugin from "vite-plugin-no-bundle";
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "");
const CJS = env.BUILD_TARGET?.toLocaleLowerCase()?.match("cjs");
const formats: LibraryFormats[] = CJS ? ["cjs"] : ["es"];
return {
plugins: [
dts({
outDir: "dist/types",
}),
react(),
noBundlePlugin({ copy: "**/*.css", root: "./src" }),
codecovVitePlugin({
enableBundleAnalysis: process.env.CODECOV_TOKEN !== undefined,
bundleName: "@knocklabs/react-native",
uploadToken: process.env.CODECOV_TOKEN,
}),
],
build: {
outDir: CJS ? "dist/cjs" : "dist/esm",
sourcemap: true,
lib: {
entry: resolve(__dirname, "src/index.ts"),
name: "react-native",
formats,
},
rollupOptions: {
// External packages that should not be bundled into your library.
external: ["react", "react-native"],
output: {
interop: "compat",
format: formats[0],
globals: {
react: "React",
},
},
},
},
};
});