Allow vite config to be defined as a "vite" key in package.json
See original GitHub issueClear and concise description of the problem
Similarly to most js mainstream tools (eslint, jest, prettier…), it would be great to be able to define simple vite config directly in the package.json in order to avoid bloating our repos with config files:
{
"name": "my-simple-package",
"version": "2.8.0",
"vite": {
"define": {
"process.env": {}
}
}
}
Suggested solution
Config resolution could use cosmiconfig which already provides an implementation to look for config both as a file and as a package.json key:
[
'package.json',
`.${moduleName}rc`,
`.${moduleName}rc.json`,
`.${moduleName}rc.yaml`,
`.${moduleName}rc.yml`,
`.${moduleName}rc.js`,
`.${moduleName}rc.cjs`,
`${moduleName}.config.js`,
`${moduleName}.config.cjs`,
]
Alternative
No response
Additional context
Couldn’t find any issue on the topic already.
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that request the same feature to avoid creating a duplicate.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:7
- Comments:15 (10 by maintainers)
Top Results From Across the Web
Configuring Vite
Note that Vite doesn't load .env files by default as the files to load can only be determined after evaluating the Vite config,...
Read more >Creating a TypeScript Package with Vite
How to create and publish a Typescript library by using Vite. ... package to publish on npm, we need to create a vite.config.ts...
Read more >Failed to load config from vite.config.js
I have a fresh Laravel installation with Jetstream/Interia but when I run 'npm install && npm run dev' I get the error 'failed...
Read more >How to Install Vite.js on your Computer?
A detailed step-by-step guide on installing and configuring Vite.js and ... Moreover, the 'package.json' file is also present, which includes 'vite' as a ......
Read more >Vite with Laravel
First, clean up Laravel's default package.json by getting rid of all Laravel Mix ... Create a vite.config.js file in the project root.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I understand what you want, it is just my opinion that adding extra code and dependencies for this to vite isn’t justified.
Theres maybe 1 in 10000 projects that will have a tiny benefit (one less file), while everyone will have to download and execute extra code and vite maintainers have to add/maintain it.
There are tools to hide files from view, you could make it
.vite.config.js
and use"dev":"vite --config .vite.config.js
" in package.json too.FYI: https://bundlephobia.com/package/cosmiconfig@7.0.1 https://bundlephobia.com/package/lilconfig@2.0.4