-
Notifications
You must be signed in to change notification settings - Fork 5
/
vite.components.config.js
39 lines (37 loc) · 1.04 KB
/
vite.components.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
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'
// this is a duplicate of the main vite config that is necessary to build the components
// for ES modules because they don't allow multiple entry points.
export default defineConfig({
plugins: [react()],
define: {
'process.env': {},
},
build: {
lib: {
entry: {
'CommentSection': path.resolve(__dirname, 'src/CommentSection.tsx'),
'CommentFilters': path.resolve(__dirname, 'src/CommentFilters.tsx')
},
formats: ['es'],
fileName: (format, entryName) => `${entryName}.${format}.js`
},
rollupOptions: {
external: ['react', 'react-dom'],
output: {
globals: {
react: 'React',
'react-dom': 'ReactDOM'
},
assetFileNames: (assetInfo) => {
if (assetInfo.name === 'style.css')
return 'components/[name].css';
return assetInfo.name;
}
}
},
outDir: 'dist/components',
sourcemap: true
}
})