Skip to content
This repository has been archived by the owner on Jan 24, 2025. It is now read-only.

Commit

Permalink
fix(docz-core): basename configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Sep 4, 2018
1 parent a293aa4 commit 5fad743
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 6 additions & 3 deletions packages/docz-core/src/bundlers/webpack/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const createConfig = (args: Args, env: Env) => async (
const base = paths.servedPath(args.base)
const dist = paths.getDist(args.dest)
const srcPath = path.resolve(paths.root, args.src)
const publicPath = isProd ? base : '/'

/**
* general
Expand Down Expand Up @@ -83,8 +84,8 @@ export const createConfig = (args: Args, env: Env) => async (

config.output
.pathinfo(true)
.path(dist)
.publicPath(isProd ? base : '/')
.path(path.resolve(paths.root, dist))
.publicPath(publicPath)
.when(isProd, outputProd, outputDev)
.crossOriginLoading('anonymous')

Expand Down Expand Up @@ -176,7 +177,8 @@ export const createConfig = (args: Args, env: Env) => async (

config.plugin('assets-plugin').use(manifestPlugin, [
{
filename: 'assets.json',
publicPath,
fileName: 'assets.json',
},
])

Expand Down Expand Up @@ -235,6 +237,7 @@ export const createConfig = (args: Args, env: Env) => async (
config.plugin('injections').use(require('webpack/lib/DefinePlugin'), [
{
...getClientEnvironment(base).stringified,
BASE_URL: args.hashRouter ? JSON.stringify('/') : JSON.stringify(base),
NODE_ENV: JSON.stringify(env),
},
])
Expand Down
4 changes: 3 additions & 1 deletion packages/docz/src/theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { ErrorBoundary } from './components/ErrorBoundary'
import { DataServer } from './components/DataServer'
import { state, State, ThemeConfig, ImportMap } from './state'

declare var BASE_URL: string

const DefaultWrapper: SFC = ({ children }) => <Fragment>{children}</Fragment>

export interface ThemeProps {
Expand Down Expand Up @@ -46,7 +48,7 @@ export function theme(
<themeContext.Provider value={themeState}>
<state.Provider initialState={props.db}>
<DataServer websocketUrl={props.websocketUrl}>
<Router>
<Router basename={BASE_URL}>
<Wrapper>
<WrappedComponent />
</Wrapper>
Expand Down

0 comments on commit 5fad743

Please sign in to comment.