question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow vite config to be defined as a "vite" key in package.json

See original GitHub issue

Clear 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

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:7
  • Comments:15 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
dominikgcommented, Feb 25, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found