-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.ts
More file actions
74 lines (71 loc) · 1.79 KB
/
Copy pathvite.config.ts
File metadata and controls
74 lines (71 loc) · 1.79 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
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';
import { resolve } from 'path';
// Create separate configs for ES and UMD builds
export default defineConfig(({ command, mode }) => {
// Base configuration shared between builds
const baseConfig = {
plugins: [
dts({ include: ['src'] })
],
resolve: {
alias: {
'@': resolve(__dirname, './src')
}
},
build: {
outDir: 'dist',
}
};
// For ES module build - can have multiple entry points
if (mode === 'es') {
return {
...baseConfig,
build: {
...baseConfig.build,
lib: {
entry: {
index: resolve(__dirname, 'src/vanilla/index.js'),
'redditify': resolve(__dirname, 'src/vanilla/auto-embed.js')
},
formats: ['es'],
fileName: (format, entryName) => `${entryName}.${format}.js`
},
rollupOptions: {
external: ['date-fns'],
output: {
globals: {
'date-fns': 'dateFns'
}
}
}
}
};
}
// For UMD build - single entry point only
return {
...baseConfig,
define: {
// Replace process.env.NODE_ENV with actual values for browser usage
'process.env.NODE_ENV': JSON.stringify('production')
},
build: {
...baseConfig.build,
lib: {
entry: resolve(__dirname, 'src/vanilla/auto-embed.js'),
formats: ['umd'],
name: 'RedditThreadViewer',
fileName: () => 'redditify.min.js'
},
rollupOptions: {
// Include date-fns in the UMD build
external: [],
output: {
globals: {},
// Generate a standalone bundle with everything included
manualChunks: undefined
}
}
}
};
});