-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvite.config.mts
More file actions
56 lines (51 loc) · 1.44 KB
/
vite.config.mts
File metadata and controls
56 lines (51 loc) · 1.44 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
44
45
46
47
48
49
50
51
52
53
54
55
56
import { defineConfig } from 'vite'
import path from 'node:path'
import react from '@vitejs/plugin-react'
import dts from 'vite-plugin-dts'
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'
import autoprefixer from 'autoprefixer'
import { name } from './package.json'
// https://vitejs.dev/config/
/**
* Removes everything before the last '/' in the package name
* @carlos8a/component-repo -> component-repo
*/
const formattedName = name.match(/[^/]+$/)?.[0] ?? 'index'
export default defineConfig({
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
'@carlos8a/react-whatsapp-floating-button': path.resolve(
__dirname,
'src/lib/components/index.ts',
),
},
},
plugins: [cssInjectedByJsPlugin(), react(), dts({ insertTypesEntry: true })],
css: {
postcss: {
plugins: [autoprefixer()],
},
},
build: {
minify: true, // TODO: Configure this to set false if NODE_ENV is 'development'
lib: {
entry: path.resolve(__dirname, 'src/lib/index.ts'),
name: formattedName,
fileName: (format) => `index.${format}.js`,
// formats: ['es', 'cjs'],
},
rollupOptions: {
external: ['react', 'react/jsx-runtime', 'react-dom'],
output: {
globals: {
react: 'React',
'react/jsx-runtime': 'react/jsx-runtime',
'react-dom': 'ReactDOM',
},
},
},
// sourcemap: true,
emptyOutDir: true,
},
})