简体   繁体   English

在 AWS 放大部署中公开的 React 源代码

[英]React source code exposed in AWS amplify deployment

I am testing deployment of an app on AWS amplify.我正在 AWS amplify 上测试应用程序的部署。 These are the steps I followed:这些是我遵循的步骤:

  1. created a sample create-react-app (called deploy_test app here),创建了一个示例 create-react-app(此处称为 deploy_test 应用程序),
  2. Pushed the code to a GitHub repo将代码推送到 GitHub 存储库
  3. AWS Amplify console > Deploy app > linked GitHub repo > used default config (as shown below) AWS Amplify 控制台 > 部署应用程序 > 链接 GitHub 存储库 > 使用默认配置(如下所示)
version: 1
frontend:
  phases:
    preBuild:
      commands:
        - yarn install
    build:
      commands:
        - yarn run build
  artifacts:
    baseDirectory: build
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

The deployment works beautifully, even when I push new changes.即使我推送新的更改,部署也能很好地工作。 The issue is that I can see the entire source code in the Chrome Dev Tools (as shown below).问题是我可以在 Chrome 开发工具中看到整个源代码(如下所示)。 Any tips on how I can resolve this?关于如何解决这个问题的任何提示?

在此处输入图像描述

by default, create-react-app will generate full sourcemaps:默认情况下,create-react-app 将生成完整的源映射:

A build script to bundle JS, CSS, and images for production, with hashes and sourcemaps.用于捆绑 JS、CSS 和用于生产的图像的构建脚本,带有散列和源映射。 https://github.com/facebook/create-react-app#whats-included https://github.com/facebook/create-react-app#whats-included

you can set GENERATE_SOURCEMAP=false before the build script:您可以在构建脚本之前设置GENERATE_SOURCEMAP=false

    build:
      commands:
        - GENERATE_SOURCEMAP=false yarn run build

you can see it defined in the source code of create-react-app webpack config:您可以在 create-react-app webpack 配置的源代码中看到它定义:

https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/config/webpack.config.js#L43-L46 https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/config/webpack.config.js#L43-L46

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM