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

[Feature]: app plugin 中配置 devServer 的问题 #173

Closed
SoloJiang opened this issue Jan 31, 2020 · 12 comments
Closed

[Feature]: app plugin 中配置 devServer 的问题 #173

SoloJiang opened this issue Jan 31, 2020 · 12 comments
Assignees
Labels

Comments

@SoloJiang
Copy link
Contributor

表现

目前 build-plugin-rax-app 支持配置 devServer 字段,但是支持以下字段:
image
其中的字段名和 webpack-dev-server 是一致的,但是并不全,比如在 Web 场景中常见的存在跨域问题,需要设置其中的 proxy,用户需要单独写一个插件来做这件事

预期

既然已经有 devServer ,应该是和 webpack-dev-server 暴露出的所有字段一致?

@SoloJiang
Copy link
Contributor Author

可以讨论一下?

@andycall
Copy link
Contributor

andycall commented Jan 31, 2020

我们参考create-react-app的方式在做吧
https://create-react-app.dev/docs/proxying-api-requests-in-development

@SoloJiang
Copy link
Contributor Author

SoloJiang commented Jan 31, 2020

还有就是 devServer 这个有限属性透出是什么考虑。。

@andycall
Copy link
Contributor

先讨论一下吧,我是觉得参照create-react-app的用法比较合适。
既支持在配置中新增一个proxy参数来实现,同时还支持src/setupProxy.js文件,因为代理这个情况比较复杂,纯配置的场景无法满足所有需求

@SoloJiang
Copy link
Contributor Author

+1,通过配置在这个场景确实不太灵活�,直接用 http-proxy-middleware 可能更好,话说其它属性呢?

@andycall
Copy link
Contributor

这个配置中除了代理还有那些功能是缺失的?

@SoloJiang
Copy link
Contributor Author

感觉还挺多的 https://webpack.docschina.org/configuration/dev-server/#devserver-progress-%E5%8F%AA%E7%94%A8%E4%BA%8E%E5%91%BD%E4%BB%A4%E8%A1%8C%E5%B7%A5%E5%85%B7-cli-,有些在 json 里配置不了,可能有些字段可能需要评估是否必要了。。

@andycall
Copy link
Contributor

我们不应该把webpack-dev-server的所有功能都暴露给用户,那样的话用户就不需要我们了,直接自己配置webpack就完事了。
现在除了提供代理功能来解决跨域问题之外,还有哪些场景是用户痛点而目前的配置却是满足不了的?

@SoloJiang
Copy link
Contributor Author

嗯,我看了一下 allowedHosts https 可能是需要的

@andycall
Copy link
Contributor

andycall commented Jan 31, 2020

OK,上班前正好有时间

@cxcshuaige
Copy link

自己写了个代理插件,但是在单页下build-plugin-rax-app这个插件里,在before里拦截了 app.get,早早的就 res.send() 出去了,后面啥也干不了,只能重制 before 吗?

@yacheng
Copy link
Contributor

yacheng commented Mar 25, 2020

重置 before 带来的问题是会丢掉服务启动等待时自动刷新页面的能力

@chenjun1011 chenjun1011 self-assigned this May 12, 2020
@chenjun1011 chenjun1011 added this to the 20200521 milestone May 12, 2020
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

6 participants