babel-plugin-replace-only-development
process.env.NODE_ENV based simple replacement plugin.
This plugin is an example for LT of metaprogram study session metapro.es.
Usage
in your .babelrc
{
"plugins": [
[
"babel-plugin-replace-only-development",
{
"rules": {
"https://api.example.com": "http://localhost:3000"
}
}
]
]
}
in your code (e.g. index.js)
import axios from 'axios'
axios.get('https://api.example.com')
Running NODE_ENV=development result
import axios from 'axios'
axios.get('http://localhost:3000')
Running NODE_ENV=production result
import axios from 'axios'
axios.get('https://api.example.com')
Installation
$ yarn add babel-pugin-replace-only-development
LICENSE
MIT