Skip to content

Instantly share code, notes, and snippets.

@Alexintosh
Last active August 6, 2019 02:26
Show Gist options
  • Save Alexintosh/ef771099efdd14012e2ad5561f286d39 to your computer and use it in GitHub Desktop.
Save Alexintosh/ef771099efdd14012e2ad5561f286d39 to your computer and use it in GitHub Desktop.
React boilerplate in subfolder
internals/webpack/webpack.base.babel.js
- publicPath: '/',
+ publicPath: '/subfolder/',
File internals/webpack/webpack.prod.babel.js
- publicPath: '/',
+ publicPath: '/subfolder/',
app/app.js
-import { applyRouterMiddleware, Router, browserHistory } from 'react-router';
+import { applyRouterMiddleware, Router, useRouterHistory } from 'react-router';
+import createBrowserHistory from 'history/lib/createBrowserHistory';
// this uses the singleton browserHistory provided by react-router
// Optionally, this could be changed to leverage a created history
// e.g. `const browserHistory = useRouterHistory(createBrowserHistory)();`
+const browserHistory = useRouterHistory(createBrowserHistory)({ basename: '/subfolder' });
const initialState = {};
app/manifest.json
- "start_url": "index.html",
+ "start_url": "/subfolder/index.html",
@brooksbecton
Copy link

Thanks! I've been looking for this solution, but couldn't get a straight answer. 👍

@lazyTai
Copy link

lazyTai commented Sep 23, 2017

how the "applyRouterMiddleware" work ??
what is the funtion!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment