-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
48 lines (47 loc) · 1.4 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
import path from 'path';
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import preserveDirectives from 'rollup-preserve-directives';
import renameNodeModules from 'rollup-plugin-rename-node-modules';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react(), preserveDirectives(), renameNodeModules('external')],
root: 'example',
build: {
lib: {
entry: {
['react-spline']: path.resolve(__dirname, './src/Spline.tsx'),
['react-spline-next']: path.resolve(
__dirname,
'./src/next/SplineNext.tsx'
),
},
name: 'react-spline',
formats: ['es'],
fileName: (format, alias) => `${alias}.${format === 'es' ? 'js' : 'cjs'}`,
},
rollupOptions: {
// make sure to externalize deps that shouldn't be bundled
// into your library
external: [
'react',
'react-dom',
'react/jsx-runtime',
'react-dom/client',
'@splinetool/runtime',
'next/image',
// these are the dependencies, they are listed in the package.json already
'blurhash',
'lodash.debounce',
'react-merge-refs',
'thumbhash',
],
output: {
// Override dist folder because root is in the example/ folder
dir: 'dist',
// Needed by preserveDirectives()
preserveModules: true,
},
},
},
});