|
| 1 | +--- |
| 2 | +description: General information based on the latest ./README.md content |
| 3 | +globs: |
| 4 | +alwaysApply: false |
| 5 | +--- |
| 6 | +<p align="center"><img src=".github/art/cover.jpg" alt="Social Card of this repo"></p> |
| 7 | + |
| 8 | +[![npm version][npm-version-src]][npm-version-href] |
| 9 | +[![GitHub Actions][github-actions-src]][github-actions-href] |
| 10 | +[](http://commitizen.github.io/cz-cli/) |
| 11 | +<!-- [![npm downloads][npm-downloads-src]][npm-downloads-href] --> |
| 12 | +<!-- [![Codecov][codecov-src]][codecov-href] --> |
| 13 | + |
| 14 | +# vite-plugin-dotenvx |
| 15 | + |
| 16 | +> A Vite plugin to seamlessly integrate with dotenvx. |
| 17 | + |
| 18 | +## Features |
| 19 | + |
| 20 | +- Automatically decrypts encrypted .env files using dotenvx |
| 21 | +- Supports multiple .env files |
| 22 | +- Supports environment-specific .env files |
| 23 | +- Supports custom .env.keys file location |
| 24 | +- Supports variable expansion and command substitution |
| 25 | +- Lightweight and easy to use |
| 26 | + |
| 27 | +## Install |
| 28 | + |
| 29 | +```bash |
| 30 | +npm install -D vite-plugin-dotenvx |
| 31 | +# or |
| 32 | +yarn add -D vite-plugin-dotenvx |
| 33 | +# or |
| 34 | +pnpm add -D vite-plugin-dotenvx |
| 35 | +# or |
| 36 | +bun add -D vite-plugin-dotenvx |
| 37 | +``` |
| 38 | + |
| 39 | +## Get Started |
| 40 | + |
| 41 | +```ts |
| 42 | +// vite.config.ts |
| 43 | +import { defineConfig } from 'vite' |
| 44 | +import Dotenvx from 'vite-plugin-dotenvx' |
| 45 | + |
| 46 | +export default defineConfig({ |
| 47 | + plugins: [ |
| 48 | + enabled: true, // default: true |
| 49 | + verbose: true, // default: false, enables detailed logging |
| 50 | + path: ['.env', '.env.local'], // default: ['.env'] |
| 51 | + envKeysFile: '.env.keys', // default: '.env.keys' |
| 52 | + overload: false, // default: false |
| 53 | + convention: 'nextjs', // optional, load envs using a convention like Next.js |
| 54 | + }) |
| 55 | + ] |
| 56 | +}) |
| 57 | +``` |
| 58 | + |
| 59 | +## Usage with dotenvx |
| 60 | + |
| 61 | +This plugin integrates with [dotenvx](https://github.com/dotenvx/dotenvx), a better dotenv from the creator of `dotenv`. It automatically decrypts encrypted .env files during development. |
| 62 | + |
| 63 | +### Encrypting your .env files |
| 64 | + |
| 65 | +First, install dotenvx globally: |
| 66 | + |
| 67 | +```bash |
| 68 | +npm install -g @dotenvx/dotenvx |
| 69 | +# or |
| 70 | +curl -sfS https://dotenvx.sh | sh |
| 71 | +``` |
| 72 | + |
| 73 | +Then encrypt your .env files: |
| 74 | + |
| 75 | +```bash |
| 76 | +dotenvx encrypt |
| 77 | +``` |
| 78 | + |
| 79 | +This will encrypt your .env file and create a .env.keys file with the encryption keys. |
| 80 | + |
| 81 | +### Using encrypted .env files |
| 82 | + |
| 83 | +The plugin will automatically decrypt your encrypted .env files during development. No additional configuration is needed. |
| 84 | + |
| 85 | +For more information on dotenvx, visit [dotenvx.com](https://dotenvx.com). |
| 86 | + |
| 87 | +## Options |
| 88 | + |
| 89 | +| Option | Type | Default | Description | |
| 90 | +|--------|------|---------|-------------| |
| 91 | +| `enabled` | `boolean` | `true` | Enable or disable the plugin | |
| 92 | +| `verbose` | `boolean` | `false` | Enable verbose logging | |
| 93 | +| `path` | `string \| string[]` | `['.env']` | Path to .env file(s) | |
| 94 | +| `envKeysFile` | `string` | `'.env.keys'` | Path to .env.keys file | |
| 95 | +| `overload` | `boolean` | `false` | Override existing env variables | |
| 96 | +| `convention` | `string` | `undefined` | Load a .env convention (e.g., 'nextjs') | |
| 97 | + |
| 98 | +## Testing |
| 99 | + |
| 100 | +```bash |
| 101 | +bun test |
| 102 | +``` |
| 103 | + |
| 104 | +## Changelog |
| 105 | + |
| 106 | +Please see our [releases](https://github.com/stacksjs/vite-plugin-dotenvx/releases) page for more information on what has changed recently. |
| 107 | + |
| 108 | +## Contributing |
| 109 | + |
| 110 | +Please review the [Contributing Guide](https://github.com/stacksjs/contributing) for details. |
| 111 | + |
| 112 | +## Community |
| 113 | + |
| 114 | +For help, discussion about best practices, or any other conversation that would benefit from being searchable: |
| 115 | + |
| 116 | +[Discussions on GitHub](https://github.com/stacksjs/stacks/discussions) |
| 117 | + |
| 118 | +For casual chit-chat with others using this package: |
| 119 | + |
| 120 | +[Join the Stacks Discord Server](https://discord.gg/stacksjs) |
| 121 | + |
| 122 | +## Postcardware |
| 123 | + |
| 124 | +"Software that is free, but hopes for a postcard." We love receiving postcards from around the world showing where `vite-plugin-dotenvx` is being used! We showcase them on our website too. |
| 125 | + |
| 126 | +Our address: Stacks.js, 12665 Village Ln #2306, Playa Vista, CA 90094, United States 🌎 |
| 127 | + |
| 128 | +## Sponsors |
| 129 | + |
| 130 | +We would like to extend our thanks to the following sponsors for funding Stacks development. If you are interested in becoming a sponsor, please reach out to us. |
| 131 | + |
| 132 | +- [JetBrains](https://www.jetbrains.com/) |
| 133 | +- [The Solana Foundation](https://solana.com/) |
| 134 | + |
| 135 | +## Credits |
| 136 | + |
| 137 | +- [Chris Breuer](https://github.com/chrisbbreuer) |
| 138 | +- [All Contributors](https://github.com/stacksjs/vite-plugin-dotenvx/contributors) |
| 139 | + |
| 140 | +## License |
| 141 | + |
| 142 | +The MIT License (MIT). Please see [LICENSE](https://github.com/stacksjs/stacks/tree/main/LICENSE.md) for more information. |
| 143 | + |
| 144 | +Made with 💙 |
| 145 | + |
| 146 | +<!-- Badges --> |
| 147 | +[npm-version-src]: https://img.shields.io/npm/v/vite-plugin-dotenvx?style=flat-square |
| 148 | +[npm-version-href]: https://npmjs.com/package/vite-plugin-dotenvx |
| 149 | +[github-actions-src]: https://img.shields.io/github/actions/workflow/status/stacksjs/vite-plugin-dotenvx/ci.yml?style=flat-square&branch=main |
| 150 | +[github-actions-href]: https://github.com/stacksjs/vite-plugin-dotenvx/actions?query=workflow%3Aci |
| 151 | + |
| 152 | +<!-- [codecov-src]: https://img.shields.io/codecov/c/gh/stacksjs/vite-plugin-dotenvx/main?style=flat-square |
| 153 | +[codecov-href]: https://codecov.io/gh/stacksjs/vite-plugin-dotenvx --> |
0 commit comments