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:
Endi 2019-04-29 22:52:16 +07:00 committed by Yangshun Tay
parent 7e300a9ada
commit 6f16335fa9
2 changed files with 5 additions and 2 deletions

View file

@ -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

View file

@ -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.