Skip to content

Commit

Permalink
fix: 修复设置 devServer 的 historyApiFallback 配置不生效问题 (#15310)
Browse files Browse the repository at this point in the history
* fix: 修复设置 devServer 的 historyApiFallback 配置不生效问题

* feat: 同步 webpack5 改动

---------

Co-authored-by: ZEJIA LIU <53506531+ZEJIA-LIU@users.noreply.github.com>
Co-authored-by: liuzejia <liuzejia@SZMAC-FV0MR4G7.local>
  • Loading branch information
3 people authored Mar 14, 2024
1 parent 66d9fbb commit 489208e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
12 changes: 7 additions & 5 deletions packages/taro-webpack-runner/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 6 additions & 4 deletions packages/taro-webpack5-runner/src/index.h5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 489208e

Please sign in to comment.