-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
34 lines (29 loc) · 1.07 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
import { defineConfig } from "vite";
import url from "node:url";
import { join, resolve } from "node:path";
import { readFileSync } from "node:fs";
import { nodeBuiltIns } from "../core/utils/config";
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
const pkg = JSON.parse(readFileSync('package.json').toString())
const pkgCore = JSON.parse(readFileSync(join('..', 'core', 'package.json')).toString())
const external = new Set([
...Object.keys(pkg.dependencies),
...Object.keys(pkgCore.dependencies),
...nodeBuiltIns
])
export default defineConfig({
build: {
emptyOutDir: false, // This is required so we always have permission to execute the development version that is installed in the global node_modules
target: 'node16',
lib: {
// Could also be a dictionary or array of multiple entry points
entry: resolve(__dirname, 'index'),
name: 'commoners',
formats: [ 'es', 'cjs' ],
fileName: (format) => `index.${format == 'es' ? 'mjs' : 'cjs'}`,
},
rollupOptions: {
external: Array.from(external),
},
},
})