Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

devServer中historyApiFallback配置rewrites规则,相关依赖包报错 #4

Closed
tudewutong opened this issue Mar 27, 2019 · 10 comments
Labels

Comments

@tudewutong
Copy link

webpack-tool版本4.4.2

场景: 一个多入口的纯前端项目, 需要针对入口配置对应的historyApiFallback规则

重现步骤和问题: devServer中historyApiFallback配置rewrites规则, 访问对应rewrite规则命中的地址, 脚本报错: 'req is not defined' , 对应报错的依赖包是koa-history-api-fallback, 报错位置line84:
logger('Rewriting', req.method, req.url, 'to', rewriteTarget);

koa-history-api-fallback的git仓库中最新代码已修复该问题, 但npm包代码是旧的, 是否可以更新webpack-tool去依赖koa-history-api-fallback的git仓库, 或者有什么别的解决办法

@hubcarl
Copy link
Collaborator

hubcarl commented Apr 3, 2019

@tudewutong 你可以在项目中直接安装 koa-history-api-fallback 修复的版本试试

@tudewutong
Copy link
Author

@hubcarl 试过在项目中安装 koa-history-api-fallback , 但是项目node_modules中的webpack-tool目录里有它自己的koa-history-api-fallback依赖包, 引不到项目安装的版本。

@hubcarl
Copy link
Collaborator

hubcarl commented Apr 3, 2019

@tudewutong koa-history-api-fallback 修复的版本是哪个? 我看看 很久没更新了。 目前 依赖里面是 ^0.1.3 已经是 latest 了

@tudewutong
Copy link
Author

@hubcarl 最新的npm包就是有问题的, 我看git仓库上已经修复了问题, 但是没有更新到npm

@hubcarl
Copy link
Collaborator

hubcarl commented Apr 3, 2019

@tudewutong 你直接修改一下 node_modules 代码, rewrite 功能可以用不?可以用的话,我就 fork 一份代码,单独发布一个包

@tudewutong
Copy link
Author

@hubcarl 可用, 按koa-history-api-fallback仓库最新代码修改是可用的

@hubcarl
Copy link
Collaborator

hubcarl commented Apr 3, 2019

@tudewutong 好的,我现在 fork 一下,重新发个版本,稍等一会

@tudewutong
Copy link
Author

@hubcarl 辛苦~

@hubcarl
Copy link
Collaborator

hubcarl commented Apr 3, 2019

@tudewutong 已经发布了,重新安装依赖即可,保证 webpack-tool 版本为 4.4.6

@hubcarl hubcarl added the bug label Apr 3, 2019
@tudewutong
Copy link
Author

@hubcarl 已解决~

@hubcarl hubcarl closed this as completed Apr 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants