-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathvite-config.mjs
More file actions
43 lines (42 loc) · 1.32 KB
/
vite-config.mjs
File metadata and controls
43 lines (42 loc) · 1.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
import { copyFileSync } from 'node:fs'
import { defineConfig } from 'vite'
import dts from 'vite-plugin-dts'
export default (entry, external = []) =>
defineConfig({
build: {
lib: {
entry,
fileName: 'index',
formats: ['es', 'cjs'],
},
minify: true,
rollupOptions: {
external: (id) => {
return id.startsWith('@opentelemetry') || external.includes(id)
},
output: {
exports: 'named',
},
},
},
define: {
PACKAGE_TIMESTAMP: new Date().getTime(),
PACKAGE_VERSION: JSON.stringify(process.env.npm_package_version || '0.0.0'),
},
plugins: [
dts({
// https://github.com/arethetypeswrong
// https://github.com/qmhc/vite-plugin-dts/issues/267#issuecomment-1786996676
afterBuild: () => {
// To pass publint (`npm x publint@latest`) and ensure the
// package is supported by all consumers, we must export types that are
// read as ESM. To do this, there must be duplicate types with the
// correct extension supplied in the package.json exports field.
copyFileSync('dist/index.d.ts', 'dist/index.d.cts')
},
compilerOptions: { skipLibCheck: true },
rollupTypes: true,
staticImport: true,
}),
],
})