-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.ts
More file actions
65 lines (62 loc) · 1.52 KB
/
vite.config.ts
File metadata and controls
65 lines (62 loc) · 1.52 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { defineConfig, Plugin } from "vite";
import { resolve } from "path";
import dts from "vite-plugin-dts";
const sourceMap = process.env.SOURCE_MAP === "true";
const minify = process.env.MINIFY === "true"; // Disable minify as default value;
const sqliteOptimizePlugin: Plugin = {
name: "sqlite-optimize",
transform(code, id) {
if (id.includes("sqlite3.mjs")) {
return code;
// .replace(
// /var ENVIRONMENT_IS_NODE =[\s\S]*?;/,
// "var ENVIRONMENT_IS_NODE = false;",
// )
// .replace(
// /var ENVIRONMENT_IS_SHELL =[\s\S]*?;/,
// "var ENVIRONMENT_IS_SHELL = false;",
// );
}
return null;
},
};
export default defineConfig({
plugins: [
sqliteOptimizePlugin,
dts({
insertTypesEntry: true,
rollupTypes: true,
tsconfigPath: "./tsconfig.json",
}),
],
build: {
lib: {
entry: resolve(__dirname, "src/main.ts"),
name: "WebSqlite",
formats: ["es"],
},
outDir: "dist",
emptyOutDir: true, // Prevent removing dist directory during build
rollupOptions: {
// External dependencies that should not be bundled
external: [],
output: {
// Ensure the output file is named index.js
entryFileNames: "index.js",
},
},
sourcemap: sourceMap,
minify: minify ? "terser" : false,
terserOptions: {
compress: {
dead_code: true,
passes: 3,
},
},
},
resolve: {
alias: {
"@": resolve(__dirname, "src"),
},
},
});