-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
51 lines (47 loc) · 1.6 KB
/
vite.config.ts
File metadata and controls
51 lines (47 loc) · 1.6 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
import { defineConfig } from 'vite';
import banner from 'vite-plugin-banner';
import react from '@vitejs/plugin-react';
import { resolve } from 'path';
import dts from 'vite-plugin-dts';
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js';
import tailwindcss from '@tailwindcss/vite';
const version = require('./package.json').version;
const bannerContent = `/*!
* react-easy-loading v${version}
* (c) Hichem Taboukouyout
* Released under the MIT License.
* Github: github.com/HichemTab-tech/react-easy-loading
*/
`;
export default defineConfig({
build: {
lib: {
entry: resolve(__dirname, 'src/index.ts'), // Library entry point
name: 'ReactEasyLoading',
fileName: (format: string) => `main${format === 'es' ? '.esm' : '.min'}.js`,
formats: ['es', 'umd']
},
rollupOptions: {
external: ['react', 'react-dom', 'react/jsx-runtime'], // Mark React, ReactDOM as external
output: {
globals: {
react: 'React',
'react-dom': 'ReactDOM',
'react/jsx-runtime': 'jsxRuntime'
}
}
}
},
plugins: [
tailwindcss(),
react(),
banner(bannerContent),
cssInjectedByJsPlugin(),
dts({
entryRoot: 'src', // Base folder for type generation
outDir: 'dist', // Ensures types go into `dist/`
insertTypesEntry: true, // Adds the `types` field in package.json
exclude: ['node_modules', 'dist'], // Exclude unnecessary files
})
]
});