For questions about using Vite, a two-part build tool (dev server + build command) that aims to provide a faster and leaner development experience for modern web projects.
Questions tagged [vite]
4741 questions
43
votes
4 answers
How to configure proxy in Vite?
I was trying to follow the docs and created vite.config.js like this:
const config = {
outDir: '../wwwroot/',
proxy: {
// string shorthand
'/foo': 'http://localhost:4567',
// with options
'/api': {
target:…

Roman Koliada
- 4,286
- 2
- 30
- 59
42
votes
5 answers
pnpm peer dependencies auto-install
How (or on which file) to set true to do auto install dependencies ?
my terminal error:
hint: If you want peer dependencies to be automatically installed, set
the "auto-install-peers" setting to "true". hint: If you don't want
pnpm to fail on peer…

fedoraname1
- 531
- 1
- 3
- 8
42
votes
1 answer
vite build always using static paths
I have a simple setup with an index.html, some js file and a sass file, building it with vite. I am using vite defaults without a config file.
After running a build the index.html in the dist folder references everything as static paths:
…

norman
- 599
- 1
- 5
- 14
40
votes
10 answers
Unable to import SVG with Vite as ReactComponent
Tried to use this library: vite-plugin-react-svg
and had no success by importing it like:
import { ExternalLink } from 'assets/svg/link-external.svg?component';
Are there any workarounds for this issue?
The error i got before was the…

Kakiz
- 1,145
- 1
- 9
- 18
36
votes
4 answers
Is there a way to debug code in VsCode initiated with Vite?
My dev team configured a Node.js project with TypeScript to use Vite as dev server, using the npm script panel of VsCode.
Is there a way to attach the debugger into this Vite server so we can debug the TSX code within the editor?

JLuis Estrada
- 685
- 1
- 7
- 15
35
votes
10 answers
How can I display the current app version from package.json to the user using Vite?
With create-react-app one could use process.env.REACT_APP_VERSION for this.
Is there an equivalent in Vite?

Obiwahn
- 2,677
- 2
- 26
- 36
30
votes
12 answers
Vite 'global is not defined'
I'm creating a project using Vite with vanilla-ts, at one point I had to use the readdir method from the fs-extra package, but it created an error saying process is not defined, some suggested I place this code in my vite-config.ts file:
import {…

8BitSoda
- 368
- 1
- 4
- 9
30
votes
5 answers
Vite / Vue 3 : "require is not defined" when using image source as props
I switched from the Vue CLI to Vite CLI, and from the Composition API of Vue 3 to SFC Script setup API.
How it previously worked for me
When I was using the official Vue CLI, I could import an image source by passing the filename of the path by the…

Dony
- 1,543
- 2
- 10
- 25
29
votes
2 answers
Using Vite for backend
We are using Vite for our frontend (inside SvelteKit) and it works nicely with creating SSR and frontend code.
I especially like the prebundling of 3rd party packages via esbuild.
Can someone tell me if it’s possible to use the Vite bundling…

user3612643
- 5,096
- 7
- 34
- 55
29
votes
7 answers
how to use sass using in vuejs3/vite
I starting with vite / vuejs 3
after installing sass with npm install -D sass I tried to add my _variables.js file this to vite.config.js
css: {preprocessorOptions: {scss: {additionalData: `@import" ./src/css/_variables.scss ";`,},},},
din't…

bluelemonade
- 1,115
- 1
- 14
- 26
29
votes
3 answers
How to add typescript to Vue 3 and Vite project
My setup: I installed Vue and Vite via the create-vite-app module, and then updated all the packages that was generated by 'init vite-app' to the very latest RC versions for Vue and Vite.
Now I want to use typescript for all my code. First I just…

Solsiden
- 673
- 1
- 7
- 22
27
votes
4 answers
Internal server error: Preprocessor dependency "sass" not found. Did you install it?
I created a new VUE 3 and typescript application using vite. I later installed primevue and primeflex. When I run npm run dev, I get the error seen below:
How do I fix this? My repo, if that will shed light.

OLA
- 861
- 2
- 11
- 23
27
votes
4 answers
How do I add types to a Vite library build?
I followed the vite documentation for using library mode and I am able to produce a working component library.
I created the project with the vue-ts preset and in my component I have defined props with their types, and used some interfaces. But…

Neelansh Mathur
- 516
- 1
- 5
- 10
27
votes
7 answers
Bundle JS and CSS into single file with Vite
I'm having a devil of a time figuring out how to build a single .js file from Vite in my Svelte project that includes all of the built javascript and CSS from my Svelte projects. By default, Vite bundles the app into one html file (this is ok), two…

ringmaster
- 2,879
- 3
- 28
- 31
26
votes
3 answers
vue component doesn't update after state changes in pinia store
I'm currently working on my first vue application, currently building the login logics.
For State management, pinia is being used. I created a Pinia Store to manage the "isLoggedIn" state globally.
import { defineStore } from "pinia";
export const…

bjørn
- 263
- 1
- 3
- 4