Skip to main content

Questions tagged [vite]

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.

3,856 questions with no upvoted or accepted answers
13 votes
0 answers
2k views

Cache transformed node modules with vite/esbuild

vite build uses esbuild to transform both the package dependencies (node modules) as well as the app source code into the target JavaScript specification, i.e. es2015. I observe that vite/esbuild re-...
Lars Blumberg's user avatar
12 votes
0 answers
495 views

Is it possible to force a <script type="module"> to be sync

When you include a <script type="module"> in an html page, its content is fetched and executed in parallel to the parsing of the page. Reference: https://v8.dev/features/modules#defer ...
EtienneT's user avatar
  • 5,327
12 votes
0 answers
6k views

Single SPA + Vite - Cannot use import statement outside a module

I am using Typescript + Vite + Single SPA Just trying to replicate the https://github.com/joeldenning/vite-single-spa-example and https://github.com/joeldenning/vite-single-spa-root-config. Hence, in ...
Eduardo Sousa's user avatar
11 votes
0 answers
748 views

vitepress env variables in markdown files

I'd like to retrieve the git build and branch data from an environment variable I can set/export at build time. is there a way I can reference such an env variable somewhere in the markdown files or ...
fessacchiotto's user avatar
10 votes
1 answer
6k views

Vue3/Vite/Vuetify 3 Build Error: Variable was not declared with !default in the @used module

I am attempting to implement SASS Variables in Vue 3, Vuetify 3, Vite build and am encountering an error about variables not being declared with !default I followed the instructions in the Vuetify 3 ...
Joel's user avatar
  • 121
10 votes
1 answer
7k views

Vitest config doesn't detect jsdom environment

I'm in a Vite/React/TypeScript application and I'm configuring my first test with Vitest. When I run my Button test (yarn vitest), I get this error: packages/frontend/src/components/Generic/Button/...
tomakazub's user avatar
  • 327
9 votes
0 answers
6k views

Uncaught ReferenceError: require is not defined in Vitejs

I am trying to build a react app with vitejs, the build is successful but when I try to serve it on browser I get this error Uncaught ReferenceError: require is not defined I have tried all the ...
psimanta's user avatar
  • 126
9 votes
1 answer
4k views

Dynamic lazy imports not working on production, using Vite

I want to to dynamically import several mdx files into a react component, e.g. I have a page that requires different mdx files depending on the selected language, so only one specific file is loaded ...
Mark Hkr's user avatar
  • 680
9 votes
1 answer
3k views

Deploying a web app using Vite, I am unable to deploy the .js file. "<script src="/index.js"> in "/index.html" can't be bundled without type="module"

When Deploying a web app using Vite, I am unable to deploy the .js file. Getting the below issue. $ vite build vite v2.8.6 building for production... **\<script src="/index.js"\> in &...
Joseph's user avatar
  • 91
9 votes
0 answers
13k views

Enable hmr overlay with vite react and ts

I have a React project with set up with vite and ts. Without ts I do have the overlay errors as we used to have errors with a basic react project. import { defineConfig } from 'vite'; import ...
David's user avatar
  • 149
8 votes
1 answer
719 views

Usin bun in docker. Cant locate postcss config file

I am trying to use bun instead of npm in docker. I have bun docker image but when I try to build inside a container an error shows that it can not find postcss config. I have my package.json set to ...
Jakub Hájek's user avatar
8 votes
1 answer
4k views

How to set up mocks for a test in a separate file with Vitest/Jest and Testing Library?

I have the following files in a React app with Vitest (which has the same API as Jest): // hooks/useEntities/useEntities.ts return useEntities() { // this hooks send api requests so I will mock ...
Matan Gubkin's user avatar
  • 3,089
8 votes
0 answers
1k views

How to cofigure HMR with nuxt 3 + vite on Gitpod web (behind proxy)

I'm new to nuxt and having trouble getting HMR websocket connection configured on a nuxt project and running in Gitpod. The project uses nuxt 3 + vite. After running yarn dev the dev server is running ...
Dave Gööck's user avatar
8 votes
0 answers
4k views

Preserve comments in Vite

When I run Vite in dev or build mode, it automatically removes any comments in JavaScript/TypeScript files. Is there a way to get Vite to keep the comments? EDIT: I've tried adding "...
siria's user avatar
  • 199
8 votes
0 answers
3k views

Vite - Multiple library entry points

After a few hours, I managed to build my custom library with multiple entry points using vite. I want to know if there is a better way to solve this problem. // vite.config.ts export default ...
Sortweste's user avatar
  • 293

15 30 50 per page
1
2 3 4 5
258