File tree Expand file tree Collapse file tree 2 files changed +5
-7
lines changed Expand file tree Collapse file tree 2 files changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -4,12 +4,6 @@ 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-
137// Register service worker for PWA
148if ( 'serviceWorker' in navigator ) {
159 window . addEventListener ( 'load' , ( ) => {
@@ -34,7 +28,7 @@ const root = createRoot(container);
3428
3529root . render (
3630 < React . StrictMode >
37- < BrowserRouter basename = { getBasename ( ) } >
31+ < BrowserRouter basename = { process . env . PUBLIC_URL || '/' } >
3832 < App />
3933 </ BrowserRouter >
4034 </ React . StrictMode > ,
Original file line number Diff line number Diff line change 11const path = require ( 'path' ) ;
2+ const webpack = require ( 'webpack' ) ;
23const HtmlWebpackPlugin = require ( 'html-webpack-plugin' ) ;
34const MiniCssExtractPlugin = require ( 'mini-css-extract-plugin' ) ;
45const CopyWebpackPlugin = require ( 'copy-webpack-plugin' ) ;
@@ -73,6 +74,9 @@ module.exports = (env, argv) => {
7374 ] ,
7475 } ,
7576 plugins : [
77+ new webpack . DefinePlugin ( {
78+ 'process.env.PUBLIC_URL' : JSON . stringify ( publicPath )
79+ } ) ,
7680 new HtmlWebpackPlugin ( {
7781 template : './public/index.html' ,
7882 favicon : './public/favicon.ico' ,
You can’t perform that action at this time.
0 commit comments