Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Merge requests
  • !3178

feature: Support specific env configs.

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/judewang/specify-env into master Sep 23, 2017
  • Overview 4
  • Commits 1
  • Pipelines 0
  • Changes 1

Created by: judewang

I found many people like me need to build and deploy to not only production server but also staging server. Since create-react-app is hard coded NODE_ENV to production during build time, I thought we can add another env variable to achieve this goal.

Here's the code examples:

In .env.staging

REACT_APP_SECRET=xxxx

In .env.production

REACT_APP_SECRET=yyyy

We can use DOTENV=staging npm run build to build our static files using .env.staging.

We also can add "build:staging": "DOTENV=staging npm run build" into scripts in our package.json and just run npm run build:staging to do the same thing. This way we can still get an optimized production build but for different deploy targets.

Reference to #2880 (closed) #790 (closed)

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/judewang/specify-env