Last active
October 18, 2022 16:04
-
-
Save codepunkt/ae82a0f3b9deb93908dc1f3d5bbc8da2 to your computer and use it in GitHub Desktop.
Host react app built with webpack in non-root directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"basePath": "/" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// usage with react-router-redux | |
import { ConnectedRouter } from 'react-router-redux' | |
import { basePath as basename } from './config.json' | |
const history = createHistory({ basename }) | |
ReactDOM.render( | |
<ConnectedRouter history={history}> | |
<App /> | |
</ConnectedRouter>, | |
document.querySelector('#app') | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// usage with react-router | |
import { BrowserRouter } from 'react-router-dom' | |
import { basePath as basename } from './config.json' | |
ReactDOM.render( | |
<BrowserRouter basename={basename}> | |
<App /> | |
</BrowserRouter>, | |
document.querySelector('#app') | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var publicPath = require('./config.json').basePath | |
module.exports = { | |
output: { | |
publicPath, | |
}, | |
devServer: { | |
publicPath, | |
historyApiFallback: { | |
index: publicPath, | |
}, | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you Christoph
The information is very use full.