-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
51 lines (48 loc) · 1.24 KB
/
vite.config.js
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
// vite.config.js
import { resolve } from "path";
import { defineConfig } from "vite";
import dts from "vite-plugin-dts";
// import { PluginOption } from "vite";
export default defineConfig({
build: {
minify: "esbuild",
target: "esnext",
lib: {
// Could also be a dictionary or array of multiple entry points
entry: resolve(__dirname, "src/lib/index.ts"),
name: "NanoSignal",
// the proper extensions will be added
fileName: "index",
formats: ["es", "umd", "cjs"],
},
},
plugins: [
...[process.env.NODE_ENV !== "development" ? customCodeStripper() : []],
// dts({
// include: "./src/lib/",
// exclude: ["./dist", "src/**/*.test.ts"],
// }),
],
});
/**
* @returns {PluginOption}
*/
export function customCodeStripper() {
return {
name: "custom-code-stripper",
enforce: "pre",
transform(code, id) {
if (id.endsWith(".ts") && !id.includes("node_modules")) {
const modifiedCode = code.replace(
/.*\/\* DEBUG START \*\/.*(\n|\r\n)?[\s\S]*?.*\/\* DEBUG END \*\/.*(\n|\r\n)?/g,
"",
);
return {
code: modifiedCode,
map: null, // No source map output
};
}
return null;
},
};
}