Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

253
Vistas
Why is '.vue' loader not found by Vite when using Vue 3 migration build?

I'm attempting to upgrade a Vue 2 project to Vue 3 using the migration build and vite (https://v3.vuejs.org/guide/migration/migration-build.html#overview)

I've done steps 1-4 (though skipped 4, since not using typescript). At this point, I get the following error:

src/main.js:3:16: error: No loader is configured for ".vue" files: src/App.vue

Despite the message, the issue appears to be with the @ alias, because if I change import App from '@/App.vue'; to import App from './App.vue'; in main.js it works fine. Any ideas? I have tried changing the alias to /src/ as well.

On the one hand, that seems like an easy fix, but on the other there are a bunch of other imports throughout the project that would have to be rewritten.

main.js:

import Vue from 'vue';
import App from '@/App.vue';

Vue.config.productionTip = false;

let app = new Vue({
  render: h => h(App)
}).$mount('#app');

vite.config.js

import { defineConfig } from 'vite';
import createVuePlugin from '@vitejs/plugin-vue';
import path from 'path';

export default defineConfig({
  plugins: [ 
      createVuePlugin({
        template: {
          compilerOptions: {
            compatConfig: {
              MODE: 2
            }
          }
        }
      }),
    ],
  resolve: {
    alias: {
      '@/': path.resolve(__dirname, './src/'),
      'vue': '@vue/compat',
    },
  },
});

package.json

{
  "name": "xxx",
  "version": "0.1.0",
  "dependencies": {
    "@vue/compat": "^3.1.0",
    "vue": "^3.1.0"
  },
  "devDependencies": {
    "@vitejs/plugin-vue": "^1.2.2",
    "@vue/compiler-sfc": "^3.1.0",
    "vite": "^2.4.1"
  }
}

I was unable to get a reproduction running in codesandbox (it doesn't appear to like the alias statements in vite.config.js at all). But this repo shows the behavior: https://github.com/dovrosenberg/vite-vue-alias-issue

The error changes sometimes (for no reason apparent to me) when using this repo to: Internal server error: Failed to resolve import "@/App.vue" from "src/main.js". Does the file exist?'

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The resolve.alias key for @ must not include the slash:

import { defineConfig } from 'vite';
import path from 'path';

export default defineConfig({
  ⋮
  resolve: {
    alias: {
      // '@/': path.resolve(__dirname, './src/'), ❌
      '@': path.resolve(__dirname, './src/'), ✅
      ⋮
    },
  },
});

demo

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda