-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
41 lines (40 loc) · 1.25 KB
/
vite.config.ts
File metadata and controls
41 lines (40 loc) · 1.25 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
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc';
import dts from 'vite-plugin-dts';
import path from 'path';
// https://vite.dev/config/
export default defineConfig({
plugins: [
react(),
dts({
insertTypesEntry: true,
tsconfigPath: './tsconfig.app.json' // <--- 添加或确保此行存在
}),
],
build: {
lib: {
entry: path.resolve(__dirname, 'src/index.ts'),
name: 'ReactScroll', // Standard PascalCase for library name
fileName: (format) => {
if (format === 'es') {
return 'react-scroll.js'; // <--- 修改这里
}
// For other formats like umd, cjs, it will be react-scroll.umd.js, react-scroll.cjs.js
return `react-scroll.${format}.js`;
},
formats: ['es', 'umd', 'cjs'], // Output formats
},
rollupOptions: {
// Make sure to externalize dependencies that you don't want to bundle into your library
external: ['react', 'react-dom'],
output: {
// Provide global variables to use in the UMD build for externalized dependencies
globals: {
react: 'React',
'react-dom': 'ReactDOM',
},
},
},
sourcemap: true, // Optional: generate sourcemaps
},
});