-
-
Save webkreation/78591c0607785a6b38b4c44963f95a5d to your computer and use it in GitHub Desktop.
Host react app built with webpack in non-root directory
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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