Vite watch is slow: transforms all node_modules and recompiles all inputs on every change #20063
-
Hi! I’m experiencing performance issues with Vite in watch mode in my project. Problem:
Environment:
My configuration: I’m using a multi-page setup with multiple entry points in rollupOptions.input and some custom output options. Here’s a relevant excerpt from my vite.config.js: export default defineConfig(({ mode }) => {
const isDev = mode === "development";
return {
mode,
plugins: [react()],
base: "/public/component/",
resolve: {
extensions: [".js", ".jsx"],
alias: {
react: resolve(__dirname, "node_modules/react"),
Common: resolve(__dirname, "common"),
// ...other aliases...
},
},
build: {
rollupOptions: {
input: {
"project-navigator": resolve(__dirname, "page/project-navigator/ProjectNavigator.jsx"),
// ...other entries...
},
output: {
format: "es",
entryFileNames: "[name]/[name].min.js",
chunkFileNames: "profields/[name].[hash].min.js",
assetFileNames: "assets/[name].[ext]",
},
maxParallelFileOps: 1000,
},
commonjsOptions: {
transformMixedEsModules: true,
requireReturnsDefault: "auto",
},
sourcemap: isDev,
minify: !isDev,
outDir: resolve(__dirname, "../src/main/resources/public/component"),
},
};
}); What I’ve tried:
None of these changes have improved the situation. Question: Is there a way to make Vite only recompile the input(s) related to the changed file, and avoid transforming all of node_modules and all entry points on every change? Is this expected behavior for multi-page setups, or am I missing some configuration to optimize incremental builds in watch mode? Any advice or pointers would be greatly appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
How do you start vite in dev? Do you run it directly or through something else? |
Beta Was this translation helpful? Give feedback.
-
It sounds like the backend integration feature may work.
|
Beta Was this translation helpful? Give feedback.
It sounds like the backend integration feature may work.
The steps for using
vite dev
for your case would probably be:server.cors.origin
to the backend server originhttp://localhost:5173/public/component/page/project-navigator/ProjectNavigator.jsx
withtype="module"
vite dev
alongside the backend server