forked from antfu-collective/sponsorkit
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
57 lines (52 loc) · 1.48 KB
/
Copy pathvite.config.ts
File metadata and controls
57 lines (52 loc) · 1.48 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
import { builtinModules } from 'node:module'
import { resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import { codecovVitePlugin } from '@codecov/vite-plugin'
import { defineConfig } from 'vite'
import packageJson from './package.json'
const rootDir = fileURLToPath(new URL('.', import.meta.url))
const runtimeDependencies = Object.keys(packageJson.dependencies)
const nodeBuiltins = new Set([
...builtinModules,
...builtinModules.map(module => `node:${module}`),
])
function isExternal(id: string) {
return nodeBuiltins.has(id) || runtimeDependencies.some(dependency => (
id === dependency || id.startsWith(`${dependency}/`)
))
}
export default defineConfig({
build: {
copyPublicDir: false,
emptyOutDir: true,
lib: {
entry: {
index: resolve(rootDir, 'src/index.ts'),
cli: resolve(rootDir, 'src/cli.ts'),
},
formats: ['es'],
fileName: (_format, entryName) => `${entryName}.mjs`,
},
minify: false,
rollupOptions: {
external: isExternal,
output: {
chunkFileNames: 'chunks/[name]-[hash].mjs',
},
},
target: 'esnext',
},
plugins: [
// The Codecov vite plugin should be after all other plugins
codecovVitePlugin({
enableBundleAnalysis: process.env.CODECOV_TOKEN !== undefined,
bundleName: 'contribkit',
uploadToken: process.env.CODECOV_TOKEN,
}),
],
resolve: {
alias: {
contribkit: resolve(rootDir, 'src/index.ts'),
},
},
})