1.0.6 • Published 2 years ago

@aminoeditor/webpack-dotenv-to-exports v1.0.6

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Dotenv to Exports Plugin

The webpack plugin you never knew you always needed

This plugin will convert your .env files to a file of individual js exports. This is really useful if you're using .env and also have other files with no access to process.env that need the environment variables as well.

Usage Example

const DotenvToExportsPlugin = require('@aminoeditor/webpack-dotenv-to-exports');
{
	...,
	plugins: [
		new DotenvToExportsPlugin({
			// the environment name
			env: process.env.NODE_ENV,
			// output filename in your /dist
			filename: './.env.js',
			// filter entries
			// return false to exclude entry
			filter (key, val) {
				return key.length && val.length;
			},
			// transform entry key
			// alters key name in the resulting file
			transformKey ({key, val}) {
				return `DOTENV_${key}`;
			},
			// transform entry value
			// alters value in resulting file
			transformValue ({key, val}) {
				if (key === 'MUST_BE_UPPER') {
					return val.toUpperCase();
				}
				return val;
			}
		})
	]
}
1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago