Fix `Configure your bundler to alias 'vue'` in Vite.js

July 8, 2022  ‐ 1 min read

You may encounter the following Vue warning saying you need to create an alias for vue. Especially when you depend on some third party Vue plugins this is lurking.

[Vue warn]: Component provided template option but runtime compilation is not supported in this build of Vue. Configure your bundler to alias "vue" to "vue/dist/vue.esm-bundler.js".

In order to resolve this warning we can create an alias in our vite config. The alias as defined below maps Vue imports to vue/dist/vue.esm-bundler.js which was given as a hint in the warning.

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

const path = require('path');

export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      vue: 'vue/dist/vue.esm-bundler.js',
    },
  },
})