File tree Expand file tree Collapse file tree 4 files changed +15
-10
lines changed Expand file tree Collapse file tree 4 files changed +15
-10
lines changed Original file line number Diff line number Diff line change 44 "private" : true ,
55 "scripts" : {
66 "start" : " webpack serve --mode development --open" ,
7- "build" : " webpack --mode production" ,
7+ "build" : " webpack --mode production --env PUBLIC_PATH='/bahnew/' " ,
88 "preview" : " webpack serve --mode production --open" ,
99 "lint" : " eslint --ext .ts,.tsx src/" ,
1010 "lint:fix" : " eslint --ext .ts,.tsx src/ --fix" ,
8686 " yarn prettier:fix"
8787 ]
8888 }
89- }
89+ }
Original file line number Diff line number Diff line change 22< html lang ="en ">
33 < head >
44 < meta charset ="utf-8 " />
5- < link rel ="icon " href ="/favicon.ico " />
65 < meta name ="viewport " content ="width=device-width, initial-scale=1 " />
76 < meta name ="theme-color " content ="#0f62fe " />
87 < meta
98 name ="description "
109 content ="Bahmni Clinical Frontend Application "
1110 />
12- < link rel ="apple-touch-icon " href ="/logo192.png " />
13- < link rel ="manifest " href ="/manifest.json " />
1411 < title > Bahmni Clinical</ title >
1512 </ head >
1613 < body >
Original file line number Diff line number Diff line change @@ -4,11 +4,17 @@ import { BrowserRouter } from 'react-router-dom';
44import App from './App' ;
55import './styles/index.scss' ;
66
7+ const getBasename = ( ) => {
8+ const pathname = window . location . pathname ;
9+ const basePath = pathname . split ( '/' ) . slice ( 0 , 2 ) . join ( '/' ) ;
10+ return basePath || '/' ;
11+ } ;
12+
713// Register service worker for PWA
814if ( 'serviceWorker' in navigator ) {
915 window . addEventListener ( 'load' , ( ) => {
1016 // Use a relative path that will work regardless of the base URL
11- const swUrl = new URL ( '/service-worker.js' , window . location . origin )
17+ const swUrl = new URL ( '. /service-worker.js' , window . location . href )
1218 . pathname ;
1319
1420 navigator . serviceWorker
@@ -28,7 +34,7 @@ const root = createRoot(container);
2834
2935root . render (
3036 < React . StrictMode >
31- < BrowserRouter >
37+ < BrowserRouter basename = { getBasename ( ) } >
3238 < App />
3339 </ BrowserRouter >
3440 </ React . StrictMode > ,
Original file line number Diff line number Diff line change @@ -8,14 +8,16 @@ const { GenerateSW } = require('workbox-webpack-plugin');
88
99module . exports = ( env , argv ) => {
1010 const isProduction = argv . mode === 'production' ;
11+ // Allow configuring the public path via environment variable
12+ const publicPath = env . PUBLIC_PATH || '/' ;
1113
1214 return {
1315 entry : './src/index.tsx' ,
1416 output : {
1517 path : path . resolve ( __dirname , 'dist' ) ,
1618 filename : isProduction ? 'static/js/[name].[contenthash:8].js' : 'static/js/[name].js' ,
1719 chunkFilename : isProduction ? 'static/js/[name].[contenthash:8].chunk.js' : 'static/js/[name].chunk.js' ,
18- publicPath : '/' ,
20+ publicPath : publicPath ,
1921 clean : true ,
2022 } ,
2123 devtool : isProduction ? 'source-map' : 'cheap-module-source-map' ,
@@ -113,8 +115,8 @@ module.exports = (env, argv) => {
113115 theme_color : '#0f62fe' , // Carbon blue
114116 display : 'standalone' ,
115117 orientation : 'portrait' ,
116- scope : '/' ,
117- start_url : '/' ,
118+ scope : publicPath ,
119+ start_url : publicPath ,
118120 icons : [
119121 {
120122 src : path . resolve ( 'public/logo512.png' ) ,
You can’t perform that action at this time.
0 commit comments