create-react-app什么时候混淆或缩小代码? [英] When does create-react-app obfuscate or minify code?

查看:102
本文介绍了create-react-app什么时候混淆或缩小代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于webpack的基本问题,可以做出反应,可以使用帮助(关于代码混淆/丑陋)。

I have kind of a basic question about webpack and react that I can use help with (around code obfuscation/uglification).

我正在为我的应用程序使用 create-react-app ,它似乎为生产创建了捆绑的版本(在运行纱线构建之后。

I am using create-react-app for my application and it appears to create a bundled build for production (after running yarn build).

在该文件中,似乎所有内容都放入了main.JS文件和main.CSS文件等。我使用 firebase deploy(在我的案件)。我希望我的代码被丑化,并且那里的任何开发人员都不能完全阅读。

And in that file it seems that everything is put into a main.JS file and main.CSS file Etc. I push this live using "firebase deploy" (in my case). I would like my code to be uglified and not be completely readable by any developer out there.

但是当我在Chrome浏览器中查看我的应用程序时,它没有显示main.JS或任何其他捆绑软件文件。它仅显示每个单独的文件以及我编写的代码。知道为什么会这样吗?为什么没有在chrome的来源标签下显示丑陋的main.js合并文件?

But when I go to look at my apps in Chrome it doesn't show main.JS or any other of the bundles files. It just shows every single individual file and exactly the code that I've written. Any idea why this is? Why doesn't it show the uglified combined main.js file under the 'sources' tab in chrome? Is this to do with the source map?

推荐答案

还有一种更好的方法可以确保不包括源地图。
在项目根文件夹中创建.env文件,并添加 GENERATE_SOURCEMAP = false 。您将获得没有源地图的构建。

There is a better way to make sure source maps are not included. Create .env file in your project root folder and add GENERATE_SOURCEMAP=false. You will get you build without source maps.

这篇关于create-react-app什么时候混淆或缩小代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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