You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A macro used with babel-plugin-macros to write configurations for multiple environments, and remove configurations are irrelevant with the specified environment from your codes finally.
The penv.macro aims to write configurations of multiple environments in one
file simultaneously and remove irrelevant configuration codes from the final bundle. If you want to know more about this plugin, please see here.
importenvfrom'penv.macro'constBASE_URL=env({development: 'https://development.example.com',staging: 'https://staging.example.com',production: (()=>'https://production.example.com')(),})// Assume that the value of `process.env.NODE_ENV` is `production`constBASE_URL=(()=>'https://production.example.com')()
With default value
importenvfrom'penv.macro'constBASE_URL=env({development: 'https://development.example.com',staging: 'https://staging.example.com',production: (()=>'https://production.example.com')(),},'defaultValue',)// Assume that the value of `process.env.NODE_ENV` didn't match anythingconstBASE_URL='defaultValue'
Advanced
The default node environment variable used to determine which property value would
be matched is NODE_ENV, if you want to change the default setting, you can customize
it by configuring babel-plugin-macros.
A macro used with babel-plugin-macros to write configurations for multiple environments, and remove configurations are irrelevant with the specified environment from your codes finally.