-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
36 lines (33 loc) · 1006 Bytes
/
vite.config.js
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
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';
import pkg from './package.json' assert { type: 'json' };
export default defineConfig({
build: {
lib: {
entry: './src/index.ts',
formats: ['es', 'cjs'], // build both ESM and CJS
fileName: (format) => `index.${format === 'es' ? 'esm.js' : 'cjs.js'}`,
},
rollupOptions: {
external: [
...Object.keys(pkg.dependencies), // don't bundle dependencies
...Object.keys(pkg.devDependencies), // don't bundle dev dependencies
/^node:.*/, // don't bundle built-in Node.js modules (use protocol imports!)
],
},
target: 'esnext', // transpile as little as possible
sourcemap: true,
},
optimizeDeps: {
// Fix imports from webpack built libraries
include: ['@10up/block-components'],
},
plugins: [
// emit TS declaration files
dts({
compilerOptions: {
noCheck: true, // Maybe enable this in the future
},
}),
],
});