How to apply resolve.extensions for dependencies? #18229
-
Hi I'm migrating some older vue 2 project from webpack to vite. Everything seems to work except one thing that I can't just solve on my own.
Now the issue I get is:
It seems that vite can't find this component because of lack of file extension. When I go to I read about My config: export default defineConfig({
plugins: [
vue2(),
Components({
resolvers: [
VuetifyResolver(),
],
}),
legacy({
targets: ['ie >= 11'],
additionalLegacyPolyfills: ['regenerator-runtime/runtime']
})
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
extensions: ['.vue', '.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json'],
},
server: {
proxy: {
"/api": BASE_PROXY_CONFIG,
//"/static": BASE_PROXY_CONFIG,
},
},
}) I tried several versions on vite from 3.x to 5.x and none worked. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I'm guessing the error is from esbuild / deps optimization and this is not necessary about |
Beta Was this translation helpful? Give feedback.
-
Kinda late but anyway, here is a solution I ended up with: imports: -import VueUploadMultipleImage from 'vue-upload-multiple-image'
+import VueUploadMultipleImage from "vue-upload-multiple-image/src/components/VueUploadMultipleImage.vue"; vite.config.js optimizeDeps: {
exclude: ['vue-image-lightbox-carousel'],
include: ['vue-awesome-swiper']
}, Since package used both imports with and without extensions I had to specify each dependency in |
Beta Was this translation helpful? Give feedback.
Kinda late but anyway, here is a solution I ended up with:
imports:
vite.config.js
Since package used both imports with and without extensions I had to specify each dependency in
include
andexclude
.Thanks @hi-ogawa for the hint!