-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
50 lines (46 loc) · 1.04 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
import commonjs from "@rollup/plugin-commonjs";
import { builtinModules } from "module";
import path from "node:path";
import modify from "rollup-plugin-modify";
import { defineConfig } from "vite";
// https://vitejs.dev/config/
export default defineConfig({
build: {
minify: true,
reportCompressedSize: true,
lib: {
entry: path.resolve(__dirname, "src/main.ts"),
fileName: "main",
formats: ["cjs"],
},
rollupOptions: {
external: [...builtinModules],
output: {
format: "cjs",
},
},
outDir: "dist",
emptyOutDir: true,
},
esbuild: {
keepNames: true,
},
resolve: {
alias: {
"@": path.join(__dirname, "src") + "/",
},
},
plugins: [
commonjs(),
modify({
find: /import\s*{\s*[\s\S]*}\s*from\s*"paperlib-api?/,
replace: (match, path) => {
const m = match
.replace(/PLAPI\s*,?\s*/g, "")
.replace(/PLExtAPI\s*,?\s*/g, "")
.replace(/PLMainAPI\s*,?\s*/g, "");
return m;
},
}),
],
});