@@ -4,22 +4,27 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
44const { CleanWebpackPlugin } = require ( 'clean-webpack-plugin' ) ;
55
66module . exports = {
7- entry : [ './src/main.ts' , './src/js/index.js' ] , // removed './src/bundle.js'
7+ // Ensure index.js (CSS + UI wiring) runs before main.ts to avoid FOUC/layout races
8+ entry : [ './src/js/index.js' , './src/main.ts' ] ,
89 mode : 'development' ,
910
1011 // Enable proper source maps for debugging (creates bundle.js.map)
1112 devtool : 'source-map' ,
1213
1314 output : {
14- filename : 'bundle.js' , // use the classic name for clarity
15+ filename : 'bundle.js' , // classic name for clarity
1516 path : path . resolve ( __dirname , 'dist' ) ,
1617 clean : true ,
18+ // important for correct chunk/asset resolution in dev and MF
19+ publicPath : '/' ,
1720 } ,
1821
1922 resolve : {
20- extensions : [ '.ts' , '.js' , '.json' ] ,
23+ extensions : [ '.ts' , '.tsx' , '. js', '.json' ] ,
2124 alias : {
22- // Optional: add alias for easier imports
25+ // Optional aliases to simplify imports and guarantee resolution
26+ '@cityManagers' : path . resolve ( __dirname , 'src/js/cityManagers' ) ,
27+ 'lodash$' : path . resolve ( __dirname , 'src/js/lodash.js' ) ,
2328 } ,
2429 } ,
2530
@@ -38,6 +43,11 @@ module.exports = {
3843 test : / \. c s s $ / i,
3944 use : [ 'style-loader' , 'css-loader' ] ,
4045 } ,
46+ // add loaders for images/fonts if your app uses them in CSS/HTML
47+ {
48+ test : / \. ( p n g | j p g | j p e g | g i f | s v g | w o f f 2 ? | e o t | t t f ) $ / ,
49+ type : 'asset/resource' ,
50+ } ,
4151 ] ,
4252 } ,
4353
@@ -47,6 +57,7 @@ module.exports = {
4757 title : 'CityGenerator' ,
4858 template : './src/html/index.html' ,
4959 filename : 'index.html' ,
60+ inject : 'body' , // ensure scripts are injected at the end of body
5061 } ) ,
5162 new ModuleFederationPlugin ( {
5263 name : 'fabcity' ,
@@ -62,6 +73,8 @@ module.exports = {
6273 'digibyte-js' : { singleton : true } ,
6374 'browserify' : { singleton : true } ,
6475 'flatbush' : { singleton : true } ,
76+ // share jdenticon only if you actually use Module Federation across remotes and hosts.
77+ 'jdenticon' : { singleton : true , eager : false , requiredVersion : false } ,
6578 } ,
6679 } ) ,
6780 ] ,
@@ -78,4 +91,11 @@ module.exports = {
7891 index : '/index.html' ,
7992 } ,
8093 } ,
94+
95+ // keep splitChunks conservative: only dynamic-imported modules are split
96+ optimization : {
97+ splitChunks : {
98+ chunks : 'async'
99+ }
100+ }
81101} ;
0 commit comments