Create constants that replace various expressions at build-time
npm install --save-dev @ptkhanh94npm/possimus-mollitia-earum
// babel.config.json
{
"plugins": [
["define-patterns", {
"replacements": {
"process.env.NODE_ENV": "production",
"typeof window": "object",
"__DEV__": true,
"require('currentBuildNumber')": 42
}
}]
]
}
Input:
process.env.NODE_ENV
Options:
{
"replacements": {
"process.env.NODE_ENV": "development"
}
}
Output:
"development"
For more examples see input.txt and output.txt.