
Product
Introducing Webhook Events for Pull Request Scans
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.
@yafh/vite-plugin-env-dts
Advanced tools
Auto generate env file declare for typescript of Vite plugins
Auto generate env file declare for typescript of Vite plugins.
npm i @yafh/vite-plugin-env-dts
// vite.config.ts
import envDts from '@yafh/vite-plugin-env-dts'
export default defineConfig({
plugins: [envDts()],
})
vite
.vite
service starts, the plug-in checks the envdir in the vite configuration and loads all env files.node_modules/@types/env-dts/index.d.ts
.For example:
.env
VITE_FOO=foo
another=hello
.env.dev
VITE_FOO=foo
VITE_BAR=bar
# multiline comment 1
# multiline comment 2
# multiline comment 3
VITE_COMMENT=comment
VITE_COMMENT_END_OF_LINE=commentEndOfLine #end-of-line comment
.env.dev.local
VITE_FOO=foo.local
VITE_LOCAL=local
.env.prod
VITE_FOO=foo.prod
declare file
/// <reference types="vite/client" />
// Auto-generated by vite-plugin-env
interface ImportMetaEnv {
/**
*
* - `default` foo
* - `dev` foo.local
* - `prod` foo.prod
*/
readonly VITE_FOO: string
/**
*
* - `dev` bar
*/
readonly VITE_BAR?: string
/**
* # multiline comment 1
* # multiline comment 2
* # multiline comment 3
* - `dev` comment
*/
readonly VITE_COMMENT?: string
/**
* #end-of-line comment
* - `dev` commentEndOfLine
*/
readonly VITE_COMMENT_END_OF_LINE?: string
}
Try convert env value to boolean or number.
env file :
# .env
VITE_FOO=bar
VITE_BOOLEAN=true
VITE_NUMBER=10
# .env.dev
VITE_FOO=2022
VITE_BOOLEAN=true
VITE_NUMBER=10
env object:
// import.meta.env
{
VITE_FOO: 'bar', // or 2022
VITE_BOOLEAN: true,
VITE_NUMBER: 10,
}
declare file:
// @types/env-dts/index.d.ts
interface ImportMetaEnv {
VITE_FOO: string | number;
VITE_BOOLEAN: boolean;
VITE_NUMBER: number;
}
env file :
VITE_FOO=bar
VITE_BOOLEAN=true
VITE_NUMBER=10
env object:
// import.meta.env
{
VITE_FOO: 'bar',
VITE_BOOLEAN: 'true',
VITE_NUMBER: '10',
}
declare file:
// @types/env-dts/index.d.ts
interface ImportMetaEnv {
VITE_FOO: string;
VITE_BOOLEAN: string;
VITE_NUMBER: string;
}
env file encoding
generate declare file in custom path. (eg: typing/env.d.ts
)
FAQs
Auto generate env file declare for typescript of Vite plugins
The npm package @yafh/vite-plugin-env-dts receives a total of 120 weekly downloads. As such, @yafh/vite-plugin-env-dts popularity was classified as not popular.
We found that @yafh/vite-plugin-env-dts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.
Research
The Socket Threat Research Team uncovered malicious NuGet packages typosquatting the popular Nethereum project to steal wallet keys.
Product
A single platform for static analysis, secrets detection, container scanning, and CVE checks—built on trusted open source tools, ready to run out of the box.