All Projects → chengjianhua → penv.macro

chengjianhua / penv.macro

Licence: MIT license
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.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to penv.macro

Extract React Types
One stop shop to document your react components.
Stars: ✭ 141 (+93.15%)
Mutual labels:  babel-plugin
Param.macro
Partial application syntax and lambda parameters for JavaScript, inspired by Scala's `_` & Kotlin's `it`
Stars: ✭ 170 (+132.88%)
Mutual labels:  babel-plugin
S2s
Coding time Compile. A tool to write code fastest.
Stars: ✭ 254 (+247.95%)
Mutual labels:  babel-plugin
Babel Plugin Object To Json Parse
This plugin converts object literal to JSON.parse
Stars: ✭ 151 (+106.85%)
Mutual labels:  babel-plugin
Babel Plugin Wildcard
Wildcard imports import a directories JS files
Stars: ✭ 170 (+132.88%)
Mutual labels:  babel-plugin
Babel Plugin Macros
🎣 Allows you to build simple compile-time libraries
Stars: ✭ 2,366 (+3141.1%)
Mutual labels:  babel-plugin
Babel Plugin Polished
Compile polished helper functions at build time
Stars: ✭ 133 (+82.19%)
Mutual labels:  babel-plugin
babel-plugin-hyperscript-to-jsx
This plugin transforms react-hyperscript into JSX. Intended to be used as codemod.
Stars: ✭ 20 (-72.6%)
Mutual labels:  babel-plugin
Babel Plugin React Html Attrs
Babel plugin which transforms HTML and SVG attributes on JSX host elements into React-compatible attributes
Stars: ✭ 170 (+132.88%)
Mutual labels:  babel-plugin
Xwind
Tailwind CSS as a templating language in JS and CSS-in-JS
Stars: ✭ 249 (+241.1%)
Mutual labels:  babel-plugin
Babel Plugin React Docgen
📝 Babel plugin to add react-docgen info into your code.
Stars: ✭ 156 (+113.7%)
Mutual labels:  babel-plugin
Babel Plugin React Css Modules
Transforms styleName to className using compile time CSS module resolution.
Stars: ✭ 1,989 (+2624.66%)
Mutual labels:  babel-plugin
Babel Plugin React Intl Auto
i18n for the component age. Auto management react-intl ID.
Stars: ✭ 203 (+178.08%)
Mutual labels:  babel-plugin
Babel Plugin Transform Incremental Dom
Turn JSX into IncrementalDOM
Stars: ✭ 146 (+100%)
Mutual labels:  babel-plugin
babel-plugin-tailwind-rn
Allows you to use className="w-full md:w-1/2" syntax in your react native projects.
Stars: ✭ 31 (-57.53%)
Mutual labels:  babel-plugin
Babel Plugin Transform Typescript Metadata
Babel plugin to emit decorator metadata like typescript compiler
Stars: ✭ 142 (+94.52%)
Mutual labels:  babel-plugin
Emotion
👩‍🎤 CSS-in-JS library designed for high performance style composition
Stars: ✭ 14,177 (+19320.55%)
Mutual labels:  babel-plugin
nornj
More exciting JS/JSX based on Template Engine, support control flow tags, custom directives, two-way binding, filters and custom operators.
Stars: ✭ 97 (+32.88%)
Mutual labels:  babel-plugin
babel-plugin-rewire-exports
Babel plugin for stubbing [ES6, ES2015] module exports
Stars: ✭ 62 (-15.07%)
Mutual labels:  babel-plugin
Eslint Import Resolver Babel Module
Custom eslint resolve for babel-plugin-module-resolver
Stars: ✭ 236 (+223.29%)
Mutual labels:  babel-plugin

penv.macro

version downloads Build Status MIT License Conventional Commits Babel Macro

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.

Language

English | 中文

Installation

This module is distributed via npm which is bundled with node and should be installed as one of your project's devDependencies:

yarn add penv.macro --dev

or

npm install penv.macro --save-dev

You'll also need to install and configure babel-macros if you haven't already.

Usage

Once you've configured babel-macros you can import/require penv.macro.

Basic

import env from 'penv.macro'

const BASE_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`
const BASE_URL = (() => 'https://production.example.com')()

With default value

import env from 'penv.macro'

const BASE_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 anything
const BASE_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.

For example in <ProjectRoot>/package.json:

{
  "dependencies": {},
  "babelMacros": {
    "penv": {
      "targetName": "NODE_ENV"
    }
  }
}

To know more details, please go to the above link.

Issues

Click here to open a new issue.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].