6

I have compiled my app via create react app: yarn build //code is minified and obfuscated as expected

I have then deployed the app via both firebase serve and firebase deploy.

my 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!
  2. my fonts are not being deployed as the media folder doesnt seem to transfer

enter image description here

The structure looks nothing like the build folder which contains the media... (necessary for fonts):

enter image description here

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"...

Again, and as always any and all direction is greatly appreciated!

6
  • 1
    You've configured Firebase Hosting to deploy whatever is in your build directory. So it seems like you have your raw source code end up in that directory. How that happens is unrelated to Firebase, but given this first line of the create-react-app tag seems like it might be expected behavior for that: "create-react-app is a starter-kit for creating React apps with no build configuration." Commented Jun 24, 2017 at 17:32
  • Thanks for the reply! I would tend to agree and it looks as though that's precisely what is happening, however that build folder is what is generated and has no raw source code in it (at least as I see it in my ide)... I will investigate further in that build directory, but something seems a miss... The create react app builds for production out of the box, yet has an eject feature to configure webpack as you see fit. I was trying to avoid configuration of webpack until it was absolutely nessesary. I hope that day isn't today! Commented Jun 24, 2017 at 17:40
  • I can confirm that running the build via local server serve -s build has all source files included, so this absolutely rules out firebase. Any create-react-app peeps wana chime in? Commented Jun 24, 2017 at 17:55
  • 1
    ...for whats its worth, it seems to be the sourcemaps: github.com/facebookincubator/create-react-app/issues/1341 Commented Jun 24, 2017 at 18:13
  • 1
    Allbeit not sexy at all the current workaround is to remove the sourcemaps: rm build/static/js/*.map rm build/static/css/*.map Commented Jun 24, 2017 at 18:24

2 Answers 2

4

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:

"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...

Sign up to request clarification or add additional context in comments.

Comments

2

Prefixing GENERATE_SOURCEMAP=false to your build target works too (which obviously doesn't generate sourcemap). In package.json file.

GENERATE_SOURCEMAP=false react-scripts build

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.