-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
43 lines (41 loc) · 1.21 KB
/
vite.config.ts
File metadata and controls
43 lines (41 loc) · 1.21 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
import { defineConfig } from "vite";
import pkg from "./package.json";
import { qwikVite } from "@builder.io/qwik/optimizer";
import tsconfigPaths from "vite-tsconfig-paths";
const { dependencies = {}, peerDependencies = {} } = pkg as any;
const makeRegex = (dep) => new RegExp(`^${dep}(/.*)?$`);
const excludeAll = (obj) => Object.keys(obj).map(makeRegex);
export default defineConfig(({ command }) => {
return {
plugins: [qwikVite(), tsconfigPaths()],
build: {
target: "esnext",
outDir: "lib",
lib: {
entry: [
"src/lib/styled/inline.tsx",
"src/lib/styled/popup.tsx",
"src/lib/index.ts",
],
fileName: (format, entry) => {
const ext = format === 'es' ? 'mjs' : 'cjs';
const name = entry;
return `${name}.qwik.${ext}`;
},
},
emptyOutDir: true,
rollupOptions: {
output: {
preserveModules: true,
preserveModulesRoot: 'src/lib',
},
// externalize deps that shouldn't be bundled into the library
external: [
/^node:.*/,
...excludeAll(dependencies),
...excludeAll(peerDependencies),
],
},
},
};
});