diff --git a/packages/taro-webpack-runner/src/index.ts b/packages/taro-webpack-runner/src/index.ts index 329f47094cd9..8d1cbd0303d0 100644 --- a/packages/taro-webpack-runner/src/index.ts +++ b/packages/taro-webpack-runner/src/index.ts @@ -167,16 +167,18 @@ const buildDev = async (appPath: string, config: BuildConfig, appHelper: AppHelp publicPath, contentBase: outputPath, writeToDisk: config.isBuildNativeComp, + proxy, + }, + baseDevServerOption, + customDevServerOption, + { historyApiFallback: { rewrites: [{ from: /./, to: publicPath }] - }, - proxy, - }, - baseDevServerOption, - customDevServerOption + } + } ) if (devServerOptions.proxy?.length < 1) { diff --git a/packages/taro-webpack5-runner/src/index.h5.ts b/packages/taro-webpack5-runner/src/index.h5.ts index 0d4f90275b70..62f394291fa9 100644 --- a/packages/taro-webpack5-runner/src/index.h5.ts +++ b/packages/taro-webpack5-runner/src/index.h5.ts @@ -261,14 +261,16 @@ async function getDevServerOptions (appPath: string, config: H5BuildConfig): Pro const pathname = chunkFilename.replace('[name]', path.basename(context.parsedUrl.pathname).replace(/\.[^.]*.hot-update\.(js|json)/, '')) return (['', 'auto'].includes(publicPath) ? '' : publicPath) + pathname } - }, { - from: /./, - to: publicPath }] }, proxy }, - customDevServerOption + customDevServerOption, + { + historyApiFallback: { + rewrites: [{ from: /./, to: publicPath }] + } + } ) const originalPort = Number(devServerOptions.port)