6,971 questions
190
votes
18
answers
392k
views
How to load environment variables from .env file using Vite
I want to load environment variables from the .env file using Vite
I used the import.meta.env object as mentioned in Docs
.env file:
TEST_VAR=123F
when trying to access this variable via the import....
169
votes
30
answers
521k
views
"vite is not recognized ..." on "npm run dev"
I'm using Node.js and npm for the first time, I'm trying to get Vite working, following the tutorials and documentation. But every time I run into the problem:
'vite' is not recognized as an internal ...
157
votes
3
answers
83k
views
Why does Vite create two TypeScript config files: tsconfig.json and tsconfig.node.json?
I'm using Vite to create a new React + TypeScript project.
After creating the project, there are two TypeScript config files on the root folder: tsconfig.json and tsconfig.node.json. These are the ...
155
votes
20
answers
85k
views
Vitest defineConfig, 'test' does not exist in type 'UserConfigExport'
Trying to setup vitest on an already existing vite (vue 3, typescript) project.
My vite.config.ts looks like this:
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
export ...
108
votes
15
answers
125k
views
Absolute path not working in Vite project React TS
I'm struggling to get absolute path to work in a Vite react-ts project.
Here's how I created the project
npm init @vitejs/app
npx: installed 6 in 1.883s
√ Project name: ... test-vite
√ Select a ...
100
votes
25
answers
178k
views
504 (Outdated Optimize Dep) while using react-vite
I installed a package called big decimal js while using React with JavaScript on Vite. On compiling, it showed the following error on the console, and the application did not load:
My package.json:
{
...
94
votes
8
answers
234k
views
Changing the input and output directory in Vite
I am using Vite (https://vitejs.dev/) for a static multipage site.
This is the default project folder structure after the build command.
my-app/
├─ node_modules/
├─ dist/
│ ├─ assets/
│ ├─ index....
87
votes
21
answers
140k
views
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 ...
78
votes
18
answers
116k
views
Vue 3 Vite - dynamic image src
I'm using Vue 3 with Vite. And I have a problem with dynamic img src after Vite build for production. For static img src there's no problem.
<img src="/src/assets/images/my-image.png" alt=...
75
votes
11
answers
63k
views
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?
73
votes
8
answers
79k
views
TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'
When Jest.js encounters import.meta in the code, I get an error:
FAIL testFile.test.ts
● Test suite failed to run
testFile.ts:40:10 - error TS1343: The 'import.meta' meta-property is only ...
70
votes
14
answers
148k
views
Vite "rollup failed to resolve" build error
Trying to build a simple Vite project that has tailwindcss in it and getting the following error, any ideas?
> [email protected] build
> vite build
vite v2.3.4 building for production...
✓ 1 ...
68
votes
5
answers
54k
views
Get error to build my project in Vite - Top-level await is not available in the configured target environment
I try to build my project in vite,
my project - https://github.com/yakovcohen4/starbucks-openlayers
I run npm run dev and all work.
but when I run to build it I get an error.
error message:
Top-level ...
63
votes
22
answers
192k
views
Vite manifest not found
I'm working on a project that is using laravel 9 and Vite with laravel-vite,
In the Dev environment everything works fine, but in production on the cPanel server I have the following issue:
Vite ...
62
votes
7
answers
52k
views
Vitest - @ src folder alias not resolved in test files
I have a vue3 project using Vite/Vitest, as recommanded in Vue.js documentation.
Here is the structure of the project:
src
components
// my Vue components here, potentially in sub-folders. For ...
52
votes
15
answers
76k
views
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 ...
52
votes
8
answers
82k
views
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 ...
49
votes
7
answers
78k
views
Import.meta.env undefined on production build vitejs
I am using Vite to statically compile my React app. However, after building, .env imports become undefined, which is not the case at the development stage.
Reading the docs, I've found out that these ...
48
votes
10
answers
95k
views
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 ...
45
votes
8
answers
114k
views
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&...
43
votes
30
answers
152k
views
Vite Server is running but not working on localhost
Vite + Reactjs server is running but I am getting
"This localhost page can’t be found
No webpage was found for the web address: https://localhost:4200/"
on the browser
40
votes
5
answers
36k
views
Uncaught SyntaxError: Export 'import_react3' is not defined in module (at chunk-ALR5B6M7.js?v=aa4e0109:17143:3)
I have a project created with create-react-app with Typescript. And I am using yarn 3.3.0 as the package manager.
Now I am trying to shift from cras webpack to vite. I have bootstrapped a project with ...
38
votes
8
answers
46k
views
Buffer is not defined in React-vite
Buffer is not defined after migrating from CRA(create react app)
"vite": "^2.7.12"
I try to add plugins, add define for Buffer, but it's not work.
const viteConfig = defineConfig({...
37
votes
5
answers
66k
views
running a vite dev server inside a docker container
I have a Vue-cli app that I'm trying to convert to vite. I am using Docker to run the server. I looked at a couple tutorials and got vite to run in development mode without errors. However, the ...
36
votes
3
answers
67k
views
Multiple entry points in Vite
I have a Vue2 project with Webpack, and I'm trying to switch from Webpack to Vite.
In webpack.common.js, I have multiple entry points:
module.exports = {
entry: {
appSchool: './resources/...