mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-06 10:20:09 +02:00
fix(v2): make sure non default baseUrl works on build & dev (#1414)
* fix non default baseUrl not working for client * fix website build for non defautl baseurl * optimize * remove console log
This commit is contained in:
parent
7e300a9ada
commit
6f16335fa9
2 changed files with 5 additions and 2 deletions
|
@ -127,7 +127,7 @@ module.exports = async function start(siteDir, cliOptions = {}) {
|
||||||
ignored: /node_modules/,
|
ignored: /node_modules/,
|
||||||
},
|
},
|
||||||
historyApiFallback: {
|
historyApiFallback: {
|
||||||
rewrites: [{from: /\.html$/, to: '/'}],
|
rewrites: [{from: /\/*/, to: baseUrl}],
|
||||||
},
|
},
|
||||||
disableHostCheck: true,
|
disableHostCheck: true,
|
||||||
// Enable overlay on browser. E.g: display errors
|
// Enable overlay on browser. E.g: display errors
|
||||||
|
|
|
@ -18,6 +18,9 @@ module.exports = function createServerConfig(props) {
|
||||||
const config = createBaseConfig(props, true);
|
const config = createBaseConfig(props, true);
|
||||||
const isProd = process.env.NODE_ENV === 'production';
|
const isProd = process.env.NODE_ENV === 'production';
|
||||||
|
|
||||||
|
const routesRelativePaths = routesPaths.map(str =>
|
||||||
|
baseUrl === '/' ? str : str.replace(new RegExp(`^${baseUrl}`), '/'),
|
||||||
|
);
|
||||||
const serverConfig = merge(config, {
|
const serverConfig = merge(config, {
|
||||||
entry: {
|
entry: {
|
||||||
main: path.resolve(__dirname, '../client/serverEntry.js'),
|
main: path.resolve(__dirname, '../client/serverEntry.js'),
|
||||||
|
@ -44,7 +47,7 @@ module.exports = function createServerConfig(props) {
|
||||||
baseUrl,
|
baseUrl,
|
||||||
outDir,
|
outDir,
|
||||||
},
|
},
|
||||||
paths: routesPaths,
|
paths: routesRelativePaths,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
// Show compilation progress bar.
|
// Show compilation progress bar.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue