0.0.2 • Published 2 years ago

unplugin-vue-dotenv v0.0.2

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

unplugin-vue-dotenv

NPM version

Auto generate the corresponding .env file.

Install

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

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

Example: playground/

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

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

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

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

This module works for both Nuxt 2 and Nuxt Vite

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

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

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

Options

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 './auto-import-image.d.ts'
   */
  dts?: string | boolean
}