Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/zyyv/unplugin-vue-dotenv

Auto generate the corresponding `.env` file.
https://github.com/zyyv/unplugin-vue-dotenv

plugin unplugin vite

Last synced: 2 months ago
JSON representation

Auto generate the corresponding `.env` file.

Awesome Lists containing this project

README

        

# unplugin-vue-dotenv

[![NPM version](https://img.shields.io/npm/v/unplugin-vue-dotenv?color=a1b858&label=)](https://www.npmjs.com/package/unplugin-vue-dotenv)

Auto generate the corresponding `.env` file.

## Install

```bash
npm i unplugin-vue-dotenv
```

Vite

```ts
// vite.config.ts
import Dotenv from 'unplugin-vue-dotenv/vite'

export default defineConfig({
plugins: [
Dotenv({ /* options */ }),
],
})
```

Example: [`playground/`](./playground/)


Rollup

```ts
// rollup.config.js
import Starter from 'unplugin-vue-dotenv/rollup'

export default {
plugins: [
Starter({ /* options */ }),
],
}
```


Webpack

```ts
// webpack.config.js
module.exports = {
/* ... */
plugins: [
require('unplugin-vue-dotenv/webpack')({ /* options */ })
]
}
```


Nuxt

```ts
// nuxt.config.js
export default {
buildModules: [
['unplugin-vue-dotenv/nuxt', { /* options */ }],
],
}
```

> This module works for both Nuxt 2 and [Nuxt Vite](https://github.com/nuxt/vite)


Vue CLI

```ts
// vue.config.js
module.exports = {
configureWebpack: {
plugins: [
require('unplugin-vue-dotenv/webpack')({ /* options */ }),
],
},
}
```


esbuild

```ts
// esbuild.config.js
import { build } from 'esbuild'
import Starter from 'unplugin-vue-dotenv/esbuild'

build({
plugins: [Starter()],
})
```


## Options
```ts
export interface Options {
/**
* Generate the corresponding `.env` file according to the mode
* @default [['']] // Only generate `.env` file
* @example [['test', true]] // Generate `.env.test` and `.env.test.local` files
*/
modes?: modeOpt[]
/**
* Filepath to generate corresponding .d.ts file.
* Default enabled when `typescript` is installed locally.
* Set `false` to disable.
*
* @default './env.d.ts'
*/
dts?: string | boolean
}
```