@@ -13,64 +13,72 @@ const __dirname = path.dirname(__filename)
1313
1414const DEV_SERVER_PORT = 2222
1515
16- export default {
17- mode : 'development' ,
18- devtool : false ,
19- target : 'web' ,
20- optimization : {
21- minimize : false ,
22- runtimeChunk : false ,
23- splitChunks : {
24- chunks : 'async' ,
25- name : false ,
26- } ,
27- } ,
28- entry : './src/index.ts' ,
29- output : {
30- clean : true ,
31- path : path . resolve ( __dirname , 'dist' ) ,
32- publicPath : 'auto' ,
33- } ,
34- resolve : {
35- extensions : [ '.ts' , '.tsx' , '.js' , '.jsx' , '.json' , '.d.ts' ] ,
36- } ,
37- plugins : [
38- new ModuleFederationPlugin ( {
39- name : 'hello' ,
40- filename : 'remoteEntry.js' ,
41- remotes : {
42- // Import some data providers from the host application
43- cyweb : 'cyweb@http://localhost:5500/remoteEntry.js' ,
44- } ,
45- exposes : {
46- './HelloApp' : './src/HelloApp' ,
47- './HelloPanel' : './src/components/HelloPanel.tsx' ,
48- './MenuExample' : './src/components/MenuExample.tsx' ,
16+ export default ( env = { } ) => {
17+ // Extract the environment variables to modify URLs and other settings
18+ const isProduction = env . production || false
19+ const cywebUrl = isProduction
20+ ? 'cyweb@https://web.cytoscape.org/remoteEntry.js'
21+ : 'cyweb@http://localhost:5500/remoteEntry.js'
22+
23+ return {
24+ mode : 'development' ,
25+ devtool : false ,
26+ target : 'web' ,
27+ optimization : {
28+ minimize : false ,
29+ runtimeChunk : false ,
30+ splitChunks : {
31+ chunks : 'async' ,
32+ name : false ,
4933 } ,
50- shared : {
51- react : { singleton : true , requiredVersion : deps . react } ,
52- 'react-dom' : { singleton : true , requiredVersion : deps [ 'react-dom' ] } ,
53- '@mui/material' : {
54- singleton : true ,
55- requiredVersion : deps [ '@mui/material' ] ,
34+ } ,
35+ entry : './src/index.ts' ,
36+ output : {
37+ clean : true ,
38+ path : path . resolve ( __dirname , 'dist' ) ,
39+ publicPath : 'auto' ,
40+ } ,
41+ resolve : {
42+ extensions : [ '.ts' , '.tsx' , '.js' , '.jsx' , '.json' , '.d.ts' ] ,
43+ } ,
44+ plugins : [
45+ new ModuleFederationPlugin ( {
46+ name : 'hello' ,
47+ filename : 'remoteEntry.js' ,
48+ remotes : {
49+ // Import some data providers from the host application
50+ cyweb : cywebUrl ,
5651 } ,
57- } ,
58- } ) ,
59- ] ,
60- module : {
61- rules : [
62- {
63- test : / \. t s x ? $ / ,
64- use : 'ts-loader' ,
65- exclude : / n o d e _ m o d u l e s / ,
66- } ,
52+ exposes : {
53+ './HelloApp' : './src/HelloApp' ,
54+ './HelloPanel' : './src/components/HelloPanel.tsx' ,
55+ './MenuExample' : './src/components/MenuExample.tsx' ,
56+ } ,
57+ shared : {
58+ react : { singleton : true , requiredVersion : deps . react } ,
59+ 'react-dom' : { singleton : true , requiredVersion : deps [ 'react-dom' ] } ,
60+ '@mui/material' : {
61+ singleton : true ,
62+ requiredVersion : deps [ '@mui/material' ] ,
63+ } ,
64+ } ,
65+ } ) ,
6766 ] ,
68- } ,
69- devServer : {
70- hot : true ,
71- port : DEV_SERVER_PORT ,
72- headers : {
73- 'Access-Control-Allow-Origin' : '*' , // allow access from any origin
67+ module : {
68+ rules : [
69+ {
70+ test : / \. t s x ? $ / ,
71+ use : 'ts-loader' ,
72+ exclude : / n o d e _ m o d u l e s / ,
73+ } ,
74+ ] ,
75+ } ,
76+ devServer : {
77+ hot : true ,
78+ port : DEV_SERVER_PORT ,
79+ headers : {
80+ 'Access-Control-Allow-Origin' : '*' , // allow access from any origin
81+ } ,
7482 } ,
75- } ,
83+ }
7684}
0 commit comments