@jswork/cra-envs
TypeScript icon, indicating that this package has built-in type declarations

1.0.15 • Public • Published

cra-envs

An env-cmd helper for cra.

version license size download

installation

npm install -D env-cmd
npm install -S @jswork/cra-envs

usage

// ---------- package.json
"scripts": {
  "start": "env-cmd -e local react-scripts start",
  "build:beta": "env-cmd -e beta react-scripts build",
  "build:prod": "env-cmd -e prod react-scripts build",
  "test": "react-scripts test",
  "eject": "react-scripts eject"
}
// ---------- .env-cmdrc.js
const CraEnvs = require('@jswork/cra-envs');

module.exports = CraEnvs.set({
  "local": {
    "API_URL": "http://localhost:3000",
    "BUILD_ENV": 'local-api.github.com/users/afeiship',
  },
  "beta": {
    "API_URL": "http://beta.api.com",
    "BUILD_ENV": 'beta-api.github.com/users/afeiship',
  },
  "production": {
    "API_URL": "http://api.com",
    "BUILD_ENV": 'api.github.com/users/afeiship',
  },
});

// ---------- src/app.tsx
// get 'BUILD_ENV'
const buildEnv = CraEnvs.get('BUILD_ENV');
// get all
const envs = CraEnvs.get();

license

Code released under the MIT license.

Dependencies (0)

    Dev Dependencies (23)

    Package Sidebar

    Install

    npm i @jswork/cra-envs

    Homepage

    js.work

    Weekly Downloads

    12

    Version

    1.0.15

    License

    MIT

    Unpacked Size

    7.75 kB

    Total Files

    8

    Last publish

    Collaborators

    • afeiship