@@ -51,6 +51,26 @@ export default defineConfig({
5151 / \/ l i b - r e a c t \/ .* \. ( j s x | t s x ) (?: \? .* ) ? $ / ,
5252 ] ,
5353 } ) ,
54+ {
55+ name : 'react-refresh-preamble-dev-only' ,
56+ apply : 'serve' ,
57+ transformIndexHtml ( ) {
58+ return [
59+ {
60+ tag : 'script' ,
61+ attrs : { type : 'module' } ,
62+ children : [
63+ "import RefreshRuntime from '/@react-refresh';" ,
64+ 'RefreshRuntime.injectIntoGlobalHook(window);' ,
65+ 'window.$RefreshReg$ = () => {};' ,
66+ 'window.$RefreshSig$ = () => (type) => type;' ,
67+ 'window.__vite_plugin_react_preamble_installed__ = true;' ,
68+ ] . join ( '\n' ) ,
69+ injectTo : 'head' ,
70+ } ,
71+ ] ;
72+ } ,
73+ } ,
5474 {
5575 name : 'serve-demo-iife-bundles' ,
5676 apply : 'serve' ,
@@ -148,8 +168,7 @@ export default defineConfig({
148168 // Do not list d3-shape here: it is not a direct dependency of this app and Vite cannot resolve it
149169 // until a charting import pulls it in (via @pie-lib/charting / recharts).
150170 include : [ 'react' , 'react-dom' , 'react/jsx-runtime' ] ,
151- // Exclude workspace packages and @pie -framework packages to prevent dependency scanning errors
152- // These are marked as external in the build config
171+ // Exclude workspace packages and @pie -framework packages to prevent dependency scanning errors.
153172 exclude : [ '@pie-element/*' , '@pie-lib/*' , '@pie-framework/*' ] ,
154173 // Vite 8 uses Rolldown for dep optimization.
155174 // Keep controller dist files external to avoid optimizer scan issues.
@@ -158,54 +177,18 @@ export default defineConfig({
158177 } ,
159178 } ,
160179
180+ ssr : {
181+ external : [ '@pie-element/element-bundler' , 'lightningcss' ] ,
182+ } ,
183+
161184 build : {
162185 rollupOptions : {
163- external : ( id ) => {
164- // Mark common dependencies that React and Svelte elements mark as external
165- // These match the external configuration in element vite configs
166- // to prevent "failed to resolve import" errors during build
167- return (
168- / ^ r e a c t ( $ | \/ ) / . test ( id ) ||
169- / ^ r e a c t - d o m ( $ | \/ ) / . test ( id ) ||
170- / ^ s v e l t e ( $ | \/ ) / . test ( id ) ||
171- / ^ @ p i e - l i b \/ / . test ( id ) ||
172- / ^ @ p i e - e l e m e n t \/ / . test ( id ) ||
173- / ^ @ p i e - f r a m e w o r k \/ / . test ( id ) ||
174- / ^ @ m u i \/ / . test ( id ) ||
175- / ^ @ e m o t i o n \/ / . test ( id ) ||
176- / ^ d 3 - / . test ( id ) ||
177- / ^ @ t e s t i n g - l i b r a r y \/ / . test ( id ) ||
178- id === 'lodash' ||
179- / ^ l o d a s h \/ / . test ( id ) ||
180- / ^ s t y l e d - c o m p o n e n t s / . test ( id ) ||
181- id === 'konva' ||
182- / ^ k o n v a \/ / . test ( id ) ||
183- id === 'react-konva' ||
184- / ^ r e a c t - k o n v a \/ / . test ( id ) ||
185- / ^ @ d n d - k i t \/ / . test ( id ) ||
186- id === '@mdi/react' ||
187- / ^ @ m d i \/ r e a c t \/ / . test ( id ) ||
188- id === '@mdi/js' ||
189- / ^ @ m d i \/ j s \/ / . test ( id ) ||
190- id === 'recharts' ||
191- / ^ r e c h a r t s \/ / . test ( id ) ||
192- [
193- 'prop-types' ,
194- 'classnames' ,
195- 'debug' ,
196- 'i18next' ,
197- 'humps' ,
198- 'mathjs' ,
199- 'react-jss' ,
200- 'js-combinatorics' ,
201- '@mapbox/point-geometry' ,
202- 'react-transition-group' ,
203- 'nested-property' ,
204- 'pluralize' ,
205- 'decimal.js' ,
206- ] . includes ( id )
207- ) ;
208- } ,
186+ external : ( id ) =>
187+ id === 'lightningcss/package.json' ||
188+ id === 'canvas' ||
189+ id === '@pie-element/element-bundler' ||
190+ id . startsWith ( '@pie-element/element-bundler/' ) ||
191+ id . includes ( '/packages/shared/bundler-shared/' ) ,
209192 } ,
210193 } ,
211194} ) ;
0 commit comments