[英]JavaScript React hiding source files in sources tab
I have recently developed a website, it's NodeJs (on Ubuntu) and running a React app.我最近开发了一个网站,它是 NodeJs(在 Ubuntu 上)并运行一个 React 应用程序。 The problem is, for example, on Chrome;
例如,问题出在 Chrome 上; when you right-click on the website and check sources you can see the source codes and all the files.
当您右键单击网站并检查源时,您可以看到源代码和所有文件。 I want to hide all of them.
我想隐藏所有这些。
In this section, I want to hide the source codes (files) in the server.在本节中,我想隐藏服务器中的源代码(文件)。
I tried couple of solutions on the internet but none of them worked.我在互联网上尝试了几种解决方案,但都没有奏效。
For example,例如,
I've added "build": "GENERATE_SOURCEMAP=false react-scripts build",
in package.json
and then I did run pm2 reload
(also yarn build etc)我在
package.json
添加了"build": "GENERATE_SOURCEMAP=false react-scripts build",
然后我确实运行了pm2 reload
(还有 yarn build 等)
I've created a file called .env
and added this line GENERATE_SOURCEMAP=false
in it.我创建了一个名为
.env
的文件,并在其中添加了这一行GENERATE_SOURCEMAP=false
。
None of them has worked.他们都没有工作。 My website is currently active right now and I want to hide source files, how can I hide these source files from sources tab so people can't see the source codes?
我的网站目前处于活动状态,我想隐藏源文件,如何从源选项卡中隐藏这些源文件,以便人们看不到源代码?
After long research, I have found the solution.经过长时间的研究,我找到了解决方案。
.env
in your project..env
的文件。 The name of the file is just .env
..env
。.env
file put this line GENERATE_SOURCEMAP=false
and save..env
文件中放置这一行GENERATE_SOURCEMAP=false
并保存。npm run build
or yarn build
.npm run build
或yarn build
。build
folder for production.build
文件夹。 After that, depends on what you are using, run this build file for running the website.pm2
on my Ubuntu server, so I've used pm2 serve build 3000 --spa
(my website is running on port 3000) Also be careful you are in the same path with the build
folder.pm2
我的Ubuntu的服务器上,所以我用pm2 serve build 3000 --spa
(我的网站在端口3000上运行),另外要小心你是在用相同的路径build
文件夹。 That's it .就是这样。 Now all the source code files are gone and website works like a charm.
现在所有的源代码文件都消失了,网站工作起来就像一个魅力。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.