-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathvite.config.js
41 lines (39 loc) · 1.09 KB
/
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
37
38
39
40
41
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { resolve } from 'path'
import pkg from './package.json'
export default defineConfig(({ mode }) => {
const shouldMinify = process.env.MINIFY !== 'false' // Check environment variable
return {
plugins: [react()],
build: {
minify: shouldMinify,
sourcemap: true,
lib: {
entry: resolve(__dirname, 'src/index.js'),
fileName: format => `index.${format}.js`,
},
rollupOptions: {
external: [
...Object.keys(pkg.dependencies), // don't bundle dependencies
...Object.keys(pkg.devDependencies),
/^node:.*/, // don't bundle built-in Node.js modules (use protocol imports!)
],
output: [
{
dir: 'dist',
format: 'es',
entryFileNames: `[name].[format].js`,
interop: 'compat',
},
{
dir: 'dist',
format: 'cjs',
entryFileNames: `[name].[format].js`,
interop: 'compat',
},
],
},
},
}
})