Skip to content

Commit 9355230

Browse files
committed
build: configure build system for React Hook support
- Change to multi-entry configuration (index and react entry points) - Remove UMD format (ES modules only) - Configure React as external dependency - Change exports from 'default' to 'auto' - Add @vitejs/plugin-react plugin for React support
1 parent 69f5c1d commit 9355230

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

vite.config.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
import { defineConfig } from 'vite';
2+
import { resolve } from 'path';
23
import dts from 'vite-plugin-dts';
34
import terser from '@rollup/plugin-terser';
45
import license from 'rollup-plugin-license';
6+
import react from '@vitejs/plugin-react';
57

68
export default defineConfig({
79
build: {
810
minify: false,
911
lib: {
10-
entry: 'src/index.ts',
11-
name: 'blokr',
12-
formats: ['es', 'umd'],
13-
fileName: format => format === 'es' ? 'index.js' : 'blokr.js',
12+
entry: {
13+
index: resolve(__dirname, 'src/index.ts'),
14+
react: resolve(__dirname, 'src/react.ts')
15+
},
16+
formats: ['es']
1417
},
1518
rollupOptions: {
19+
external: ['react'],
1620
output: {
17-
exports: 'default',
21+
entryFileNames: '[name].js',
22+
exports: 'auto',
1823
plugins: [
1924
license({
2025
banner: '@license\nCopyright 2025 KNOWLEDGECODE\nSPDX-License-Identifier: MIT'
@@ -25,6 +30,7 @@ export default defineConfig({
2530
}
2631
},
2732
plugins: [
33+
react(),
2834
dts({
2935
include: ['src/**/*']
3036
})

vitest.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { defineConfig } from 'vitest/config';
22
import { playwright } from '@vitest/browser-playwright';
3+
import react from '@vitejs/plugin-react';
34

45
export default defineConfig({
6+
plugins: [react()],
57
test: {
68
browser: {
79
enabled: true,

0 commit comments

Comments
 (0)