11const path = require ( 'path' ) ;
22
33exports . onCreateWebpackConfig = ( { actions, getConfig } ) => {
4- // Allows importing html files for component code examples
54 actions . setWebpackConfig ( {
65 module : {
76 rules : [
@@ -19,15 +18,25 @@ exports.onCreateWebpackConfig = ({ actions, getConfig }) => {
1918 ] ,
2019 } ,
2120 resolve : {
21+ // Ensure node_modules are in the path for resolution
2222 modules : [ path . resolve ( __dirname , 'src' ) , 'node_modules' ] ,
2323 alias : {
24- // light-weight fork of buble compiler from react-live team
2524 buble : path . resolve ( __dirname , 'node_modules' , '@philpl/buble' ) ,
25+ // Explicitly resolve @carbon packages to their node_modules path
26+ '@carbon/react' : path . resolve ( __dirname , 'node_modules/@carbon/react' ) ,
27+ '@carbon/icons-react' : path . resolve ( __dirname , 'node_modules/@carbon/icons-react' ) ,
28+ '@carbon/styles' : path . resolve ( __dirname , 'node_modules/@carbon/styles' ) , // Keep for Sass if needed
2629 } ,
30+ // Fallback for older module resolution patterns
31+ fallback : {
32+ 'crypto' : false , // Example of adding fallbacks if needed for older modules
33+ 'stream' : false ,
34+ 'path' : require . resolve ( 'path-browserify' ) , // Ensure path resolves correctly
35+ // You might need more if other 'cannot resolve' errors appear for node built-ins
36+ }
2737 } ,
2838 } ) ;
2939
30- // Disable sourcemaps in production
3140 if ( getConfig ( ) . mode === 'production' ) {
3241 actions . setWebpackConfig ( {
3342 devtool : false ,
@@ -38,7 +47,6 @@ exports.onCreateWebpackConfig = ({ actions, getConfig }) => {
3847exports . createPages = ( { actions } ) => {
3948 const { createRedirect } = actions ;
4049
41- // Community index
4250 createRedirect ( {
4351 fromPath : '/community/components' ,
4452 toPath : '/community/component-index' ,
@@ -50,7 +58,6 @@ exports.createPages = ({ actions }) => {
5058 isPermanent : true ,
5159 } ) ;
5260
53- // Developing
5461 createRedirect ( {
5562 fromPath : '/resources' ,
5663 toPath : '/developing/developer-resources' ,
@@ -97,7 +104,6 @@ exports.createPages = ({ actions }) => {
97104 isPermanent : true ,
98105 } ) ;
99106
100- // Case studies
101107 createRedirect ( {
102108 fromPath : ' /case-studies/overview' ,
103109 toPath : '/all-about-carbon/who-uses-carbon/' ,
@@ -114,7 +120,6 @@ exports.createPages = ({ actions }) => {
114120 isPermanent : true ,
115121 } ) ;
116122
117- // Data-visualization
118123 createRedirect ( {
119124 fromPath : '/data-visualization/basic-charts' ,
120125 toPath : '/data-visualization/simple-charts' ,
@@ -126,7 +131,6 @@ exports.createPages = ({ actions }) => {
126131 isPermanent : true ,
127132 } ) ;
128133
129- // Elements L0 - 2022/02
130134 createRedirect ( {
131135 fromPath : '/guidelines/2x-grid/overview' ,
132136 toPath : '/elements/2x-grid/overview' ,
@@ -247,4 +251,4 @@ exports.createPages = ({ actions }) => {
247251 toPath : '/elements/typography/code' ,
248252 isPermanent : true ,
249253 } ) ;
250- } ;
254+ } ;
0 commit comments