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

[webpack] webpack-dev-server 为何不适用于线上环境?【热度: 88】 #655

Open
yanlele opened this issue Dec 26, 2023 · 0 comments
Labels
TOP100互联网 公司标签 工程化 web 项目工程化
Milestone

Comments

@yanlele
Copy link
Member

yanlele commented Dec 26, 2023

关键词:webpack-dev-server 作用

webpack-dev-server并不适用于线上环境的原因有以下几点:

  1. 性能问题:webpack-dev-server是一个开发服务器,它将编译后的文件保存在内存中,并提供给浏览器访问。这种方式在开发阶段可以提供快速的编译和热模块替换,但在线上环境中,内存中保存的文件无法持久化,每次启动服务器都需要重新编译和打包,这会影响性能,并且占用服务器资源。

  2. 安全问题:webpack-dev-server并不进行代码压缩和混淆,源代码是以明文形式传输给浏览器的。这将使得攻击者可以很容易地获取到项目的源代码,从而可能导致安全漏洞。

  3. 缺少文件输出:webpack-dev-server并没有生成最终的打包文件,它只是将打包后的文件保存在内存中,提供给浏览器访问。这样就无法进行资源的版本管理和持久化存储,无法做到长期的缓存和优化。

@yanlele yanlele added TOP100互联网 公司标签 工程化 web 项目工程化 labels Dec 26, 2023
@yanlele yanlele added this to the milestone Dec 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TOP100互联网 公司标签 工程化 web 项目工程化
Projects
None yet
Development

No branches or pull requests

1 participant