create-react-app在生产中显示我的所有代码,如何将其隐藏? [英] create-react-app is showing all my code in production, how to hide it?

查看:128
本文介绍了create-react-app在生产中显示我的所有代码,如何将其隐藏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Chrome来源标签中,我可以按确切的文件夹位置查看所有文件。我怎么藏起来?

In my chrome sources tab, I am able to view all my files by exact folder location. How can I hide them?

这些不是我以前的项目中的问题,这些项目是在不使用create-react-app的情况下完成的。

These weren't the problem in my previous project, which were made without using create-react-app.

推荐答案

根据问题#1632

Gaeron


这是预期的。如果您想禁用
,则可以从生成输出中删除.map文件,尽管会收到有关
丢失的控制台警告。

This is expected. You can delete .map files from the build output if you want to disable it, although you'll get console warnings about them missing.

没有虽然我认为将它们留在里面是有害的。客户端代码
已可用于用户的计算机,因此
中没有任何秘密。

There is no harm in leaving them in though in my opinion. Client code is already available to the user’s machine so there’s no secrets in it.

还要确保您具有正确的生产版本, npm run build / yarn build 的输出就是应该部署到服务器的输出。

Also ensure you have proper production build, the output of npm run build/yarn build is the one which should be deployed to your server.

如果要完全禁用生成源地图,请使用:

If you want to completely disable generation of source maps use:

scripts: {
  "build": "GENERATE_SOURCEMAP=false react-scripts build"
}

您还可以指定 GENERATE_SOURCEMAP = false 参数通过 .env 配置文件或在普通控制台命令中使用 GENERATE_SOURCEMAP = false react-scripts build

You can also specify GENERATE_SOURCEMAP=false parameter via .env configuration files or use in plain console command GENERATE_SOURCEMAP=false react-scripts build.

这篇关于create-react-app在生产中显示我的所有代码,如何将其隐藏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆