-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathvite.config.ts
81 lines (76 loc) · 2.23 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import path, { basename } from "node:path";
import { createRequire } from "node:module";
import { defineConfig } from "vite";
import dts from "vite-plugin-dts";
import { globbySync } from "globby";
import { babel } from "@rollup/plugin-babel";
const require = createRequire(import.meta.url);
const manifest = require("./package.json");
let entryFiles = globbySync(["src/**/*.ts"], { ignore: ["**/*.d.ts"] });
let entries: Record<string, string> = {};
for (let entry of entryFiles) {
let name = basename(entry);
entries[name] = entry;
}
export default defineConfig({
// esbuild in vite does not support decorators
// https://github.com/evanw/esbuild/issues/104
esbuild: false,
build: {
outDir: "dist",
// These targets are not "support".
// A consuming app or library should compile further if they need to support
// old browsers.
target: ["esnext", "firefox121"],
// In case folks debug without sourcemaps
//
// TODO: do a dual build, split for development + production
// where production is optimized for CDN loading via
// https://limber.glimdown.com
minify: false,
sourcemap: true,
rollupOptions: {
output: {
dir: "dist",
experimentalMinChunkSize: 0,
format: "es",
hoistTransitiveImports: false,
sourcemap: true,
entryFileNames: (entry) => {
const { name, facadeModuleId } = entry;
const fileName = `${name}.js`;
if (!facadeModuleId) {
return fileName;
}
const relativeDir = path.relative(
path.resolve(__dirname, "src"),
path.dirname(facadeModuleId),
);
return path.join(relativeDir, fileName);
},
},
external: [
...Object.keys(manifest.dependencies || {}),
...Object.keys(manifest.peerDependencies || {}),
],
},
lib: {
entry: entries,
name: "signal-utils",
formats: ["es"],
},
},
plugins: [
babel({
babelHelpers: "inline",
extensions: [".js", ".ts"],
}),
dts({
// This can generate duplicate types in the d.ts files
// rollupTypes: true,
outDir: "declarations",
// ignore tests
include: ["src"],
}),
],
});