Vite
WebStorm integrates with the Vite build tool that improves the frontend development experience. Vite consists of a dev server and a build command. The build server serves your source files over native ES modules. The build command bundles your code with Rollup, which is pre-configured to output highly optimized static assets for production.
WebStorm supports tsconfig.json and jsconfig.json path mappings in Vue style
tags and recognizes Vite aliases.
In projects that consist of multiple modules with different Vite configurations, WebStorm can automatically detect the relevant configuration file for each module and use the module resolution rules from it, see Specifying the Vite configuration file to use below.
Before you start
Make sure you have Node.js on your computer.
Scaffold your Vite project as described on the Vite.js official website.
Alternatively, download your project from a Version Control System. See Creating projects for details.
Configure Vite in WebStorm
Add Vite to your package.json
Make sure Vite is listed in the
dependencies
ordevDependencies
object of your package.json.If Vite is missing, open the embedded Terminal (Alt+F12) and type:
npm install --save-dev vite
Create Vite configuration files
Create one or several configuration files depending on your project structure: select a parent folder in the Project tool window and then select from the context menu.
The acceptable names are vite.config.js/vite.config.ts, vite.config.mjs, or vite.config.cjs.
Learn more from the Vite official website.
If necessary, use
alias
that will be later recognized inimport
statements. Make sure you specify absolute paths in definitions of aliases. Learn more from the Vite official website.
Specify the Vite configuration files to use
Based on the analysis of a Vite configuration file, WebStorm understands the Vite configuration, resolves modules, and provides coding assistance in JavaScript and TypeScript files.
In WebStorm, you can choose between two configuration modes - automatic and manual.
With automatic configuration, WebStorm auto-detects the relevant Vite configuration file for each JavaScript or TypeScript file.
With manual configuration, you specify the Vite configuration file to use in your project. Manual configuration is useful if the name of your Vite configuration file is not recognized by WebStorm, see the list of recognized Vite config names below.
Choose how to detect Vite configuration
Open the Settings/Preferences dialog (Ctrl+Alt+S) and go to .
In the Detect Vite configuration files for module resolution area, select one of the following options:
Automatically: In this mode, for a JavaScript or TypeScript file, WebStorm will first look for a Vite configuration file in the folder where this JavaScript or TypeScript file is located, then in its parent folder, and so on.
As a result, if your project consists of multiple modules with different Vite configurations, each module will use the module resolution rules from its own Vite configuration file (if such config is found).
WebStorm recognizes JavaScript or TypeScript Vite configuration files with the following names and in the following order:
vite.config.js/vite.config.ts
vite.config.mjs
vite.config.cjs
Manually: In the Configuration file field, specify the location of the Vite config to use.
In this mode, the resolution rules from the specified configuration file will be applied to all modules in your project.
Select this option if the name of your Vite configuration file is not recognized by WebStorm, see the list of recognized Vite config names above.