-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
43 lines (42 loc) · 1.41 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
import { defineConfig } from 'vite';
import path from 'path';
import tsconfigPaths from 'vite-tsconfig-paths'
import dts from 'vite-plugin-dts'
// Vite configuration for library development
export default defineConfig({
plugins: [tsconfigPaths(), dts()], // Use TypeScript paths plugin
build: {
lib: {
entry: path.resolve(__dirname, 'src/index.ts'), // Entry point for the library
// name: 'WxSDK', // Global variable for UMD build
formats: ['es', 'cjs'], // Output formats
fileName: (format) => {
return format === 'es' ? 'index.esm.js' : 'index.js';
}
},
rollupOptions: {
external: [
'ioredis',
'cross-fetch',
'@nuecms/sdk-builder',
'crypto', //
'buffer'
], // Mark dependencies as external
output: {
globals: {
'cross-fetch': 'fetch', // Use fetch in the browser
'ioredis': 'Redis', // Global for Redis in Node.js
},
},
},
sourcemap: false, // Enable source maps for debugging
emptyOutDir: true, // Clean output directory before building
},
resolve: {
alias: {
'@api': path.resolve(__dirname, 'src/api'),
'@cache': path.resolve(__dirname, 'src/cache'),
'@transformers': path.resolve(__dirname, 'src/transformers'),
},
}
});