-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
38 lines (36 loc) · 1.14 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
import { defineConfig } from "vite";
import { qwikVite } from "@builder.io/qwik/optimizer";
import tsconfigPaths from "vite-tsconfig-paths";
import { vanillaExtractPlugin } from "styled-vanilla-extract/vite";
import pkg from "./package.json";
const {
dependencies = {},
devDependencies = {},
peerDependencies = {},
} = pkg as any;
const makeRegex = (dep: string) => new RegExp(`^${dep}(/.*)?$`);
const excludeAll = (obj: { [pkg: string]: string }) =>
Object.keys(obj).map(makeRegex);
export default defineConfig(() => {
return {
build: {
target: "es2020",
lib: {
entry: ["./src/index.ts", "./src/styledRuntime.tsx"],
formats: ["es", "cjs"],
fileName: (format, entryName) =>
`${entryName}.qwik.${format === "es" ? "mjs" : "cjs"}`,
},
rollupOptions: {
// externalize deps that shouldn't be bundled into the library
external: [
/^node:.*/,
...excludeAll(dependencies),
...excludeAll(devDependencies),
...excludeAll(peerDependencies),
],
},
},
plugins: [qwikVite(), tsconfigPaths(), vanillaExtractPlugin()],
};
});