forked from SGFGOV/medusa-payment-phonepe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
108 lines (106 loc) · 2.32 KB
/
vite.config.ts
File metadata and controls
108 lines (106 loc) · 2.32 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import dts from "vite-plugin-dts";
import { defineConfig } from "vitest/config";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
export default defineConfig({
plugins: [
// Generate TypeScript declaration files
dts({
include: ["src/**/*"],
exclude: [
"src/**/__tests__/**",
"src/**/__mocks__/**",
"src/**/__fixtures__/**",
],
outDir: "dist",
copyDtsFiles: true,
tsconfigPath: resolve(__dirname, "tsconfig.json"),
}),
],
build: {
lib: {
entry: resolve(__dirname, "src/index.ts"),
name: "MedusaPaymentPhonePe",
fileName: "index",
formats: ["cjs"],
},
outDir: "dist",
sourcemap: true,
rollupOptions: {
output: {
// Preserve directory structure for proper module resolution
preserveModules: true,
preserveModulesRoot: "src",
entryFileNames: "[name].js",
// Ensure consistent naming
chunkFileNames: "chunks/[name]-[hash].js",
assetFileNames: "assets/[name][extname]",
},
external: (id) => {
// Externalize peer dependencies
if (
id === "@medusajs/framework" ||
id.startsWith("@medusajs/framework/") ||
id === "axios" ||
id === "express" ||
id === "typeorm" ||
// Externalize Node.js built-ins
id.startsWith("node:") ||
[
"crypto",
"fs",
"path",
"os",
"http",
"https",
"url",
"util",
"stream",
"events",
"buffer",
"querystring",
"zlib",
"net",
"tls",
"child_process",
"cluster",
"dgram",
"dns",
"readline",
"repl",
"string_decoder",
"timers",
"tty",
"vm",
"worker_threads",
].includes(id)
) {
return true;
}
// Don't externalize local dependencies
return false;
},
},
target: "node18",
// Don't bundle dependencies - they're peer dependencies
commonjsOptions: {
transformMixedEsModules: true,
},
},
resolve: {
alias: {
"@": resolve(__dirname, "./src"),
},
},
test: {
environment: "node",
include: ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],
globals: false,
sequence: {
hooks: "list",
},
testTimeout: 1000000000, // 1e9 milliseconds to match jest.setTimeout(1e9)
},
});