rollup / awesome

⚡️ Delightful Rollup Plugins, Packages, and Resources
MIT License
2.55k stars 139 forks source link

rollup-plugin-baked-env #105

Closed victornpb closed 2 years ago

victornpb commented 2 years ago

Awesome Contribution Checklist:

Please Provide a Link A Repository for Your Addition

https://github.com/victornpb/rollup-plugin-baked-env

Please Describe Your Addition

This plugin allow you to use environment variables inside your code by importing process.env as a faux module. The environment variable will be baked into your bundle at compile time. It leverages rollup tree shakable modules to only include variables being used. Compilation fails if there are imports to unset variables.

import { NODE_ENV, FOO, BAR } from 'process.env';

console.log(FOO, BAR);
if (NODE_ENV === 'production') {
    // code
}
shellscape commented 2 years ago

thanks!