File tree Expand file tree Collapse file tree 4 files changed +27
-24
lines changed
commerce-sdk-react/src/types
template-retail-react-app/app/components/page-designer-init Expand file tree Collapse file tree 4 files changed +27
-24
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 7070 "commander" : " ^9.5.0" ,
7171 "compression" : " 1.7.4" ,
7272 "copy-webpack-plugin" : " ^9.1.0" ,
73- "css-loader" : " ^6.8.1" ,
7473 "cross-env" : " ^5.2.1" ,
7574 "eslint" : " ^8.37.0" ,
7675 "eslint-config-prettier" : " 8.8.0" ,
102101 "semver" : " ^7.5.2" ,
103102 "source-map-loader" : " ^4.0.1" ,
104103 "speed-measure-webpack-plugin" : " ^1.5.0" ,
105- "style-loader" : " ^3.3.3" ,
106104 "svg-sprite-loader" : " ^6.0.11" ,
107105 "validator" : " ^13.9.0" ,
108106 "webpack" : " ^5.76.3" ,
Original file line number Diff line number Diff line change @@ -280,11 +280,7 @@ const baseConfig = (target) => {
280280 loader : findDepInStack ( 'source-map-loader' )
281281 }
282282 } ,
283- target === 'web' && {
284- test : / \. c s s $ / ,
285- use : [ findDepInStack ( 'style-loader' ) , findDepInStack ( 'css-loader' ) ]
286- } ,
287- target === 'node' && {
283+ {
288284 test : / \. c s s $ / ,
289285 loader : findDepInStack ( 'ignore-loader' )
290286 }
@@ -358,6 +354,15 @@ const staticFolderCopyPlugin = new CopyPlugin({
358354 . replace ( / \\ / g, '/' ) ,
359355 to : `static/` ,
360356 noErrorOnMissing : true
357+ } ,
358+ {
359+ // Copy Page Designer CSS from storefront-next-runtime for dynamic loading
360+ from : path . resolve (
361+ projectDir ,
362+ 'node_modules/@salesforce/storefront-next-runtime/dist/design-styles.css'
363+ ) ,
364+ to : 'static/pd-design-styles.css' ,
365+ noErrorOnMissing : true
361366 }
362367 ]
363368} )
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import {
1111 usePageDesignerMode ,
1212 useGlobalAnchorBlock
1313} from '@salesforce/commerce-sdk-react/page-designer'
14+ import { getAssetUrl } from '@salesforce/pwa-kit-react-sdk/ssr/universal/utils'
1415
1516/**
1617 * PageDesignerInit - Component that handles Page Designer initialization
@@ -59,14 +60,25 @@ export function PageDesignerInit() {
5960 // Pass isDesignMode to control when navigation blocking is active
6061 useGlobalAnchorBlock ( isDesignMode )
6162
62- // Dynamically import the Page Designer global styles only when in design mode.
63+ // Dynamically load the Page Designer global styles only when in design mode.
6364 // This ensures the styles are not loaded in production runtime, improving performance.
6465 useEffect ( ( ) => {
65- if ( isDesignMode ) {
66- // Dynamic import with void to ignore the promise
67- // Import only the CSS file, not the entire components module to avoid circular dependencies
68- void import ( '@salesforce/storefront-next-runtime/design/styles.css' )
66+ if ( ! isDesignMode ) {
67+ return
6968 }
69+
70+ const id = 'pd-design-styles'
71+ if ( document . getElementById ( id ) ) {
72+ return
73+ }
74+
75+ const link = document . createElement ( 'link' )
76+ link . id = id
77+ link . rel = 'stylesheet'
78+ link . href = getAssetUrl ( 'static/pd-design-styles.css' )
79+ document . head . appendChild ( link )
80+
81+ return ( ) => link . remove ( )
7082 } , [ isDesignMode ] )
7183
7284 // When the message function returns false, navigation is completely blocked (no dialog shown)
You can’t perform that action at this time.
0 commit comments