Skip to content

Commit

Permalink
Version_0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
censujiang committed May 25, 2023
1 parent 3b24f9b commit 9f38d73
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,50 @@
# vite-plugin-global-const

Define constants for your project to facilitate reuse of your code across multiple products

## INSTALL

```bash
npm i vite-plugin-global-const -D
#or
yarn add vite-plugin-global-const -D
```

## CONFIG

In your `vite.config.js`, you can add your global constants to the plugin options.For example:

```js
// vite.config.js
import { defineConfig } from 'vite'
import {globalConst} from 'vite-plugin-global-const'

export default defineConfig({
plugins: [
globalConst({
// Global constants for your needs
MAIN: true
}),
],
})

```

## USAGE

You can use the global constants in your code, they are injected into the `import.meta.env` object.For example:

```js
// content.js
const main = import.meta.env.MAIN
console.log(main)
```

```console
# browser console/terminal
true
```

## LAST

If you have any questions, please submit an issue, thank you for your support, and if you like this plugin, please give me a star, thank you!

0 comments on commit 9f38d73

Please sign in to comment.