-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
84 lines (82 loc) · 2.47 KB
/
vite.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
80
81
82
83
84
/*
* Echoes React
* Copyright (C) 2023-2024 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import react from '@vitejs/plugin-react';
import path from 'node:path';
import license from 'rollup-plugin-license';
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';
import * as packageJson from './package.json';
// https://vitejs.dev/config/
export default defineConfig({
build: {
lib: {
entry: path.resolve('src/index.ts'),
name: 'Echoes',
formats: ['es'],
fileName: `index`,
},
outDir: 'dist',
rollupOptions: {
external: [
'react/jsx-runtime',
'@emotion/react/jsx-runtime',
...Object.keys(packageJson.peerDependencies),
],
output: {
intro: `import './style.css';`,
globals: {
react: 'react',
'react-dom': 'ReactDOM',
},
plugins: [
license({
sourcemap: true,
banner: {
commentStyle: 'ignored',
content: {
file: path.resolve(__dirname, 'config/license/LICENSE-BANNER.txt'),
},
},
}),
],
},
},
},
optimizeDeps: {
esbuildOptions: {
target: 'es2022',
},
},
plugins: [
react({ jsxImportSource: '@emotion/react', babel: { plugins: ['@emotion/babel-plugin'] } }),
dts({
entryRoot: 'src',
exclude: ['**/config/**', '**/stories/**', '**/__tests__/**', '**/*-stories.*'],
}),
],
resolve: {
alias: {
'~common': path.resolve(__dirname, './src/common'),
'~generated': path.resolve(__dirname, './src/generated'),
'~utils': path.resolve(__dirname, './src/utils'),
'~types': path.resolve(__dirname, './src/types'),
},
},
});