-
Notifications
You must be signed in to change notification settings - Fork 30
/
vite.lib.config.ts
66 lines (62 loc) · 2.25 KB
/
vite.lib.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
import path from 'path';
import { lingui } from '@lingui/vite-plugin';
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
import { externalizeDeps } from 'vite-plugin-externalize-deps';
import dts from '@beda.software/vite-plugin-dts';
export default defineConfig({
plugins: [
react({
babel: {
plugins: [
'macros',
[
'babel-plugin-styled-components',
{
displayName: true,
fileName: true,
meaninglessFileNames: ['index', 'styles'],
},
],
],
},
}),
lingui(),
dts({ entryRoot: 'src/', exclude: ['node_modules/**', '**/*.stories.ts*'] }),
externalizeDeps(),
],
resolve: {
alias: [{ find: 'src', replacement: path.resolve(__dirname, './src/') }],
},
build: {
copyPublicDir: false,
lib: {
entry: [
path.resolve(__dirname, 'src/index.ts'),
path.resolve(__dirname, 'src/components/index.ts'),
path.resolve(__dirname, 'src/containers/index.ts'),
path.resolve(__dirname, 'src/hooks/index.ts'),
path.resolve(__dirname, 'src/utils/index.ts'),
path.resolve(__dirname, 'src/services/index.ts'),
path.resolve(__dirname, 'src/contexts/index.ts'),
path.resolve(__dirname, 'src/theme/index.ts'),
path.resolve(__dirname, 'src/dashboard.config.ts'),
path.resolve(__dirname, 'src/setupTests.ts'),
],
formats: ['es'],
fileName: (format, entryName) => `${entryName}.js`,
},
rollupOptions: {
output: {
preserveModules: true,
preserveModulesRoot: 'src/',
entryFileNames: (chunkInfo) => {
if (chunkInfo.name.includes('node_modules')) {
return chunkInfo.name.replace(/node_modules/g, 'ext') + '.js';
}
return '[name].js';
},
},
},
},
});