https://github.com/webdeveric/esbuild-plugin-environment
esbuild plugin to define process.env variables
https://github.com/webdeveric/esbuild-plugin-environment
esbuild-plugin plugin
Last synced: 2 months ago
JSON representation
esbuild plugin to define process.env variables
- Host: GitHub
- URL: https://github.com/webdeveric/esbuild-plugin-environment
- Owner: webdeveric
- License: mit
- Created: 2022-11-21T07:20:48.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-03-14T13:48:56.000Z (about 1 year ago)
- Last Synced: 2024-03-14T15:09:47.251Z (about 1 year ago)
- Topics: esbuild-plugin, plugin
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/esbuild-plugin-environment
- Size: 780 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# `esbuild-plugin-environment`
[](https://github.com/webdeveric/esbuild-plugin-environment/actions)
## Install
```sh
npm install esbuild-plugin-environment -D
```## Usage
Add the plugin to your esbuild `plugins`.
Example `esbuild.config.cjs` file:
```js
const { environmentPlugin } = require('esbuild-plugin-environment');module.exports = () => {
const config = {
bundle: true,
sourcemap: true,
platform: 'node',
target: 'es2022',
format: 'esm',
outputFileExtension: '.mjs',
environment: {},
concurrency: 4,
watch: {
pattern: ['./src/**'],
ignore: ['dist', 'node_modules'],
},
plugins: [
// process.env key => default value
environmentPlugin({
BUILD_TIMESTAMP: new Date().toISOString(),
}),
// Array of process.env keys
environmentPlugin(['PWD', 'npm_package_version']),
],
};return config;
};
```