This repository was archived by the owner on Dec 22, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change 5454 "coverage" : " vitest --coverage" ,
5555 "upgrade-interactive" : " npm-check -u"
5656 },
57- "dependencies" : {
58- "react" : " ^17.0.0" ,
59- "react-dom" : " ^17.0.0"
57+ "dependencies" : {},
58+ "peerDependencies" : {
59+ "@emotion/react" : " ^11.9.0" ,
60+ "react" : " ^17.0.0 || ^18.0.0" ,
61+ "react-dom" : " ^17.0.0 || ^18.0.0"
6062 },
6163 "devDependencies" : {
6264 "@babel/core" : " 7.18.0" ,
Original file line number Diff line number Diff line change @@ -3,6 +3,14 @@ import react from '@vitejs/plugin-react';
33import dts from 'vite-plugin-dts' ;
44import packageJson from './package.json' ;
55
6+ const makeExternalPredicate = ( externals : string [ ] ) => {
7+ if ( externals . length === 0 ) {
8+ return ( ) => false ;
9+ }
10+ const pattern = new RegExp ( `^(${ externals . join ( '|' ) } )($|/)` ) ;
11+ return ( id : string ) => pattern . test ( id ) ;
12+ } ;
13+
614// https://vitejs.dev/config/
715export default defineConfig ( {
816 build : {
@@ -12,17 +20,19 @@ export default defineConfig({
1220 fileName : ( format ) => `react-vite-storybook-typescript-starter.${ format } .js` ,
1321 } ,
1422 rollupOptions : {
15- external : [ 'react' ] ,
23+ external : makeExternalPredicate ( [ ... Object . keys ( packageJson . dependencies ) , ... Object . keys ( packageJson . peerDependencies ) ] ) ,
1624 output : {
1725 globals : {
1826 react : 'React' ,
27+ '@emotion/react' : '@emotion/react' ,
1928 } ,
2029 } ,
2130 } ,
2231 } ,
2332 plugins : [
2433 react ( {
2534 jsxImportSource : '@emotion/react' ,
35+ exclude : [ / \. s t o r i e s \. ( t | j ) s x ? $ / , / n o d e _ m o d u l e s / ] ,
2636 babel : {
2737 plugins : [ '@emotion/babel-plugin' ] ,
2838 } ,
You can’t perform that action at this time.
0 commit comments