-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
75 lines (74 loc) · 1.74 KB
/
vite.config.ts
File metadata and controls
75 lines (74 loc) · 1.74 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { defineConfig, UserConfig } from 'vite'
import path from 'path'
import react from '@vitejs/plugin-react'
import postcssPresetEnv from 'postcss-preset-env'
// import postcssGlobalData from '@csstools/postcss-global-data'
// https://vite.dev/config/
export default defineConfig(async ({ command }) => {
const baseConfig: UserConfig = {
base: './',
plugins: [
react()
],
resolve: {
alias: {
'@': path.resolve(__dirname, './')
}
},
server: {
port: 3000,
host: '0.0.0.0'
},
css: {
devSourcemap: true,
postcss: {
plugins: [
// postcssGlobalData({
// files: ['./lib/styles/utils/breakpoints.css']
// }),
postcssPresetEnv()
]
}
}
}
if (command === 'build') {
return {
...baseConfig,
build: {
outDir: './dist',
cssCodeSplit: true,
lib: {
entry: './lib/index.ts',
name: 'FeaturesReact',
formats: ['es', 'umd'],
fileName: (format) => {
switch (format) {
case 'es':
return 'index.js'
case 'umd':
return 'index.umd.js'
default:
return `index.${format}.js`
}
}
},
// lib: {
// entry: {
// 'index': './lib/index.ts',
// },
// },
rollupOptions: {
external: ['react', 'react-dom', 'react/jsx-runtime'],
output: {
globals: {
react: 'React',
'react-dom': 'ReactDOM',
'react/jsx-runtime': 'ReactJSXRuntime'
}
}
}
},
} as UserConfig
}
return baseConfig
})