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

refactor: 调整env的判断方式,避免用户手动构建时将console提示打包到生产环境bundle #3915

Closed
wants to merge 1 commit into from

Conversation

paranoidjk
Copy link
Contributor

console

问题

蚂蚁金融云的console里看到了如上图antd的warning

跟踪代码

结论

  • 猜测金融云可能是开发者手动构建antd,然而没有指定process.env.NODE_ENV='production'
  • 这个PR改了下判断的方式,确保只有指定了development环境的构建bundle才会包含有warning

@mention-bot
Copy link

@paranoidjk, thanks for your PR! By analyzing the history of the files in this pull request, we identified @afc163, @Brooooooklyn and @infeng to be potential reviewers.

@yesmeck
Copy link
Member

yesmeck commented Nov 18, 2016

生产环境构建的时候就应该设置 NODE_ENV='production',这样 React 也会有性能上的提升 https://facebook.github.io/react/docs/optimizing-performance.html#use-the-production-build。

@paranoidjk
Copy link
Contributor Author

@yesmeck 你说的实践没错 💯 但我理解这个warning的目的是:当用户引用了未压缩的antd开发的时候,提示他用babe-plugin-import插件来打包以减少最后上线的静态文件大小;

至于生产环境构建的时候应该设置 NODE_ENV='production',这个可以在文档里说明,或者改下这个warning的内容?

anyway,我只是无意看到到了金融云console里的提示,强迫症...

@afc163
Copy link
Member

afc163 commented Nov 19, 2016

NODE_ENV='production' 应该是业界通行的规则,不是 antd 特有的配置。

@benjycui benjycui closed this Nov 21, 2016
@benjycui
Copy link
Contributor

不过现在的确是有很多 warning 没有加环境判断,然后被打包进生产环境了。

@paranoidjk 这个改动会更有意义 #3930

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants