-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.publish.config.ts
79 lines (74 loc) ยท 1.85 KB
/
vite.publish.config.ts
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
76
77
78
79
import { resolve } from 'path';
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';
import tsconfigPaths from 'vite-tsconfig-paths';
import pkg from './package.json';
const makeExternalPredicate = (externalArr: string[]) => {
if (externalArr.length === 0) {
return () => false;
}
const pattern = new RegExp(`^(${externalArr.join('|')})($|/)`);
return (id: string) => pattern.test(id);
};
const externals = makeExternalPredicate(Object.keys(pkg.peerDependencies));
export default defineConfig({
build: {
lib: {
entry: resolve(__dirname, 'src/index.ts'),
name: 'index',
fileName: 'index',
formats: ['es', 'umd'],
},
rollupOptions: {
external: externals,
output: {
globals: {
react: 'React',
'@emotion/react/jsx-runtime': 'jsxRuntime',
'@emotion/react': 'react',
'@emotion/styled': 'styled',
},
},
},
},
plugins: [
react(),
tsconfigPaths(),
dts({
copyDtsFiles: true,
}),
],
resolve: {
alias: [
{
find: '@components',
replacement: resolve(__dirname, './src/components'),
},
{
find: '@components-common',
replacement: resolve(__dirname, './src/components/@common'),
},
{
find: '@components-layout',
replacement: resolve(__dirname, './src/components/@layout'),
},
{
find: '@constants',
replacement: resolve(__dirname, './src/constants'),
},
{
find: '@styles',
replacement: resolve(__dirname, './src/styles'),
},
{
find: '@utils',
replacement: resolve(__dirname, './src/utils'),
},
{
find: '@util-types',
replacement: resolve(__dirname, './src/utils/types'),
},
],
},
});