File tree Expand file tree Collapse file tree 4 files changed +27
-5
lines changed Expand file tree Collapse file tree 4 files changed +27
-5
lines changed Original file line number Diff line number Diff line change
1
+ // @flow
2
+
3
+ // this module is ran on node before webpack bundles it.
4
+
5
+ /* eslint-disable import/no-commonjs */
6
+
7
+ // need to import from /lib (the version in which webpack is running) otherwise it will use /es
8
+ const config = require ( '../../../lib/shared/framework-config' ) ;
9
+
10
+ module . exports = function getRouteDeclarations ( ) {
11
+
12
+ const routerKey = config . default . routingType === 'hash' ? 'HashRouter' : 'BrowserRouter' ;
13
+
14
+ return {
15
+ code : `
16
+ export { ${ routerKey } as Router } from 'react-router-dom';
17
+ ` ,
18
+ } ;
19
+ } ;
Original file line number Diff line number Diff line change
1
+ // @flow
2
+
1
3
import React from 'react' ;
2
4
import ReactDOM from 'react-dom' ;
3
- import { createBrowserHistory } from 'history' ;
4
- import { Router } from 'react-router-dom' ;
5
5
import { CookiesProvider } from 'react-cookie' ;
6
6
import serverStyleCleanup from 'node-style-loader/clientCleanup' ;
7
7
import { loadableReady } from '@loadable/component' ;
8
+ import { Router } from 'val-loader!./_react-router' ;
8
9
import { getDefault } from '../../shared/util/ModuleUtil' ;
9
10
import ReworkRootComponent from '../app/ReworkRootComponent' ;
10
11
import { rootRoute } from '../common/kernel' ;
11
12
import BrowserLanguageProvider from './browser-language-provider' ;
12
13
import ClientHooks from './client-hooks' ;
13
14
14
- // TODO: support hashHistory somehow (cli option ?)
15
-
16
15
let rootComponent = (
17
16
< BrowserLanguageProvider >
18
17
< CookiesProvider >
19
18
< ReworkRootComponent >
20
- < Router history = { createBrowserHistory ( ) } >
19
+ < Router >
21
20
{ rootRoute }
22
21
</ Router >
23
22
</ ReworkRootComponent >
Original file line number Diff line number Diff line change @@ -5,6 +5,9 @@ export type FrameworkPluginConfig = {
5
5
} ;
6
6
7
7
export type FrameworkConfigStruct = {
8
+
9
+ routingType : 'browser' | 'hash' ,
10
+
8
11
directories : {
9
12
logs : string ,
10
13
build : string ,
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ function getUserConfig() {
40
40
41
41
function normalizeConfig ( config : Object ) {
42
42
const schema = Joi . object ( ) . keys ( {
43
+ routingType : Joi . string ( ) . valid ( [ 'browser' , 'hash' ] ) . default ( 'browser' ) ,
43
44
routes : Joi . string ( ) . default ( 'src/**/*.route.js' ) ,
44
45
'entry-react' : Joi . string ( ) . allow ( null ) . default ( null ) ,
45
46
'render-html' : Joi . string ( ) . allow ( null ) . default ( null ) ,
You can’t perform that action at this time.
0 commit comments