1.1.5 • Published 3 years ago

postenv v1.1.5

Weekly downloads
78
License
ISC
Repository
github
Last release
3 years ago

postenv

postenv is a tool helping to inject environment variables into pre-built frontend using env from the system it runs on. It allows us to use the same docker image in all environments (in example staging and production).

Usage of this package with React application consist of four steps.

Step 1

Install the tool into your React app:

npm install postenv

Step 2

Add import script to your page head section, before ReactDOM.render is executed:

    <head>
      ...
      <script src="__postenv.generated.js"></script>
    </head>

Step 3

Use your environment variables where you need it:

import { env } from 'postenv'

console.log(env.POSTENV_BACKEND_URL)

Step 4

Run init binary before you serve the static frontend application, i.e. before serve command:

    "scripts": {
        "serve": "npx postenv init build POSTENV_ && serve -s build"
    }
      

The postenv init command accepts two arguments. First one is a root directory of your pre-built React application. Second argument is the prefix of the system variables that will be included in the generated env file available in the React application.


Check out https://purpledeer.studio

1.1.5

3 years ago

1.1.4

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.33

3 years ago

1.0.32

3 years ago

1.0.31

3 years ago

1.0.30

3 years ago

1.0.29

3 years ago

1.0.28

3 years ago

1.0.27

3 years ago

1.0.26

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.22

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.25

3 years ago

1.0.23

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago