-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.react.config.ts
More file actions
33 lines (32 loc) · 1.07 KB
/
Copy pathvite.react.config.ts
File metadata and controls
33 lines (32 loc) · 1.07 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
import { resolve } from 'node:path';
import { defineConfig } from 'vite';
import { litCssPlugin } from './litcss';
// React wrappers entry. `@lit/react` is bundled in; react/react-dom stay
// external (optional peer deps) and lit stays external for dedupe.
export default defineConfig({
plugins: [litCssPlugin()],
resolve: {
dedupe: ['lit', '@lit/context'],
},
build: {
outDir: 'dist/react',
emptyOutDir: false,
lib: {
entry: resolve(import.meta.dirname, 'src/react/index.ts'),
formats: ['es'],
fileName: () => 'index.js',
},
rollupOptions: {
// Externalise react/lit and the library's own modules (they ship in the
// main build); the react entry bundles only @lit/react + the wrappers.
external: (id: string) =>
id === 'react' ||
id === 'react-dom' ||
id === 'lit' ||
id.startsWith('lit/') ||
id === '@lit/context' ||
/[\\/]src[\\/](components|generated|context|base)[\\/]/.test(id) ||
/\.\.[\\/](components|generated|context|base)[\\/]/.test(id),
},
},
});