-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(basename): setup basename and redirects
- Loading branch information
1 parent
88e360f
commit 3c58e1b
Showing
12 changed files
with
68 additions
and
50 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
export default (config) => ({ | ||
compiler_devtool: 'source-map', | ||
|
||
export default (config) => { | ||
// We use an explicit public path in development to resolve this issue: | ||
// http://stackoverflow.com/questions/34133808/webpack-ots-parsing-error-loading-fonts/34133809#34133809 | ||
compiler_public_path: `http://${config.server_host}:${config.server_port}/`, | ||
}) | ||
const __BASE__ = `http://${config.server_host}:${config.server_port}/` | ||
|
||
return { | ||
compiler_devtool: 'source-map', | ||
compiler_public_path: __BASE__, | ||
compiler_globals: { | ||
...config.compiler_globals, | ||
__BASE__: JSON.stringify(__BASE__), | ||
}, | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
export default () => ({ | ||
const __BASE__ = '/stardust/' | ||
|
||
export default (config) => ({ | ||
compiler_fail_on_warning: true, | ||
compiler_hash_type: 'chunkhash', | ||
compiler_devtool: false, | ||
// html-webpack-plugin will insert assets into the index.html based on public path | ||
// this needs to be relative on gh-pages otherwise assets try to serve from | ||
// technologyadvice.github.io/ | ||
// ...instead of | ||
// technologyadvice.github.io/stardust | ||
compiler_public_path: '', | ||
compiler_public_path: __BASE__, | ||
compiler_globals: { | ||
...config.compiler_globals, | ||
__BASE__: JSON.stringify(__BASE__), | ||
}, | ||
}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"globals": { | ||
"__BASE__": false, | ||
"__DEV__": false, | ||
"__DEBUG__": false, | ||
"__STAGING__": false, | ||
"__TEST__": false, | ||
"__PROD__": false | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
import React, { Component } from 'react' | ||
import { Router, browserHistory } from 'react-router' | ||
import { Router, useRouterHistory } from 'react-router' | ||
import { createHistory } from 'history' | ||
|
||
import routes from './routes' | ||
|
||
const history = useRouterHistory(createHistory)({ | ||
basename: __BASE__, | ||
}) | ||
|
||
export default class App extends Component { | ||
render() { | ||
return ( | ||
<Router history={browserHistory} routes={routes} /> | ||
<Router history={history} routes={routes} /> | ||
) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<!-- baseHref value already includes quotes "/foo" --> | ||
<base href=<%= htmlWebpackPlugin.options.baseHref %> /> | ||
<title>Stardust</title> | ||
<script> | ||
// Apply gh-pages SPA redirect that was applied in 404.html | ||
(function() { | ||
var redirect = sessionStorage.redirect | ||
delete sessionStorage.redirect | ||
if (redirect && redirect !== location.href) { | ||
history.replaceState(null, null, redirect) | ||
} | ||
})() | ||
</script> | ||
</head> | ||
<body> | ||
|
||
</body> | ||
</html> |
This file was deleted.
Oops, something went wrong.
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
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