Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
545 views
in Technique[技术] by (71.8m points)

javascript - 创建反应应用程序的firebase部署会在“源”选项卡中公开所有js代码?(firebase deploy of create react app exposes all js code in the source tab?)

I have compiled my app via create react app: yarn build //code is minified and obfuscated as expected(我已经通过create react应用程序编译了我的应用程序: yarn build //code is minified and obfuscated as expected)

I have then deployed the app via both firebase serve and firebase deploy .(然后,我已经通过firebase servefirebase deploy部署了该应用程序。)

my firebase.json:(我的firebase.json:)

{
  "database": {
    "rules": "database.rules.json"
  },
  "hosting": {
    "public": "build",
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}

All is deployed "almost as expected", with 2 caveats:(所有部署均“几乎按预期进行”,但有两个警告:)

  1. inside Chrome developer tools/ Sources tab, my entire js codebase is listed with no minification and or obfuscation!(在Chrome开发者工具/“来源”标签中,列出了我的整个js代码库,没有缩小或混淆!)
  2. my fonts are not being deployed as the media folder doesnt seem to transfer(我的字体没有被部署,因为媒体文件夹似乎没有转移)

在此处输入图片说明

The structure looks nothing like the build folder which contains the media... (necessary for fonts):(该结构看起来不像包含媒体的build文件夹...(字体必需):)

在此处输入图片说明

Am I setting something up incorrectly, deploying the wrong folder or possibly not ignoring something I should be?(我设置不正确,部署了错误的文件夹还是可能忽略了我应该设置的内容?)

Exposing the entire js stack unminified and or without any obfuscation seems very "un-secure"...(暴露整个js堆栈未缩小和/或没有任何混淆似乎非常“不安全” ...)

Again, and as always any and all direction is greatly appreciated!(再次,一如既往地非常感谢任何方向!)

  ask by studiobrain translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Strongly advise to refer to the create-react-app github discussion here about this matter but as a quick workaround you can add the following to your package.json scripts:(强烈建议您参考此处的create-react-app github讨论作为快速解决方法,您可以将以下内容添加到package.json脚本中:)

"scripts": {
    ...
    "build": "npm run build-css && react-scripts build && yarn run delete-maps",
    "delete-maps": "rm ./build/static/js/*.map && rm ./build/static/css/*.map",
    ...
}

This will however in the short run remove all of your source code from the Source tab in developer tools...(但是,这将在短期内从开发人员工具的“源”选项卡中删除所有源代码...)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...