mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-03 00:39:45 +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/,
|
||||
},
|
||||
historyApiFallback: {
|
||||
rewrites: [{from: /\.html$/, to: '/'}],
|
||||
rewrites: [{from: /\/*/, to: baseUrl}],
|
||||
},
|
||||
disableHostCheck: true,
|
||||
// Enable overlay on browser. E.g: display errors
|
||||
|
|
|
@ -18,6 +18,9 @@ module.exports = function createServerConfig(props) {
|
|||
const config = createBaseConfig(props, true);
|
||||
const isProd = process.env.NODE_ENV === 'production';
|
||||
|
||||
const routesRelativePaths = routesPaths.map(str =>
|
||||
baseUrl === '/' ? str : str.replace(new RegExp(`^${baseUrl}`), '/'),
|
||||
);
|
||||
const serverConfig = merge(config, {
|
||||
entry: {
|
||||
main: path.resolve(__dirname, '../client/serverEntry.js'),
|
||||
|
@ -44,7 +47,7 @@ module.exports = function createServerConfig(props) {
|
|||
baseUrl,
|
||||
outDir,
|
||||
},
|
||||
paths: routesPaths,
|
||||
paths: routesRelativePaths,
|
||||
}),
|
||||
|
||||
// Show compilation progress bar.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue