-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,22 @@ | ||
import { defineConfig } from 'vite' | ||
import { createVuePlugin } from 'vite-plugin-vue2' | ||
import createVuePlugin from '@vitejs/plugin-vue' | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [createVuePlugin()] | ||
resolve: { | ||
alias: { | ||
vue: '@vue/compat' | ||
This comment has been minimized.
Sorry, something went wrong. |
||
} | ||
}, | ||
plugins: [ | ||
createVuePlugin({ | ||
template: { | ||
compilerOptions: { | ||
compatConfig: { | ||
MODE: 2 | ||
This comment has been minimized.
Sorry, something went wrong.
yyx990803
Author
Member
|
||
} | ||
} | ||
} | ||
}) | ||
] | ||
}) |
1 comment
on commit 14f6f18
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this step we are actually swapping Vue 2 to Vue 3 migration build.
The migration build should work with Vue Router 3.x & Vuex 3.x. You will likely see a lot of console warnings but the application should still be able to run.
If you are using vue-cli
:
- update
vue
version to^3.1.0
- install
@vue/compat
with same version - replace
vue-template-compiler
with@vue/compiler-sfc@^3.1.0
Then configure the alias and compiler options in vue.config.js
:
module.exports = {
chainWebpack: config => {
config.resolve.alias.set('vue', '@vue/compat')
config.module
.rule('vue')
.use('vue-loader')
.tap(options => {
return {
...options,
compilerOptions: {
compatConfig: {
MODE: 2
}
}
}
})
}
}
Alias
vue
to the migration build (@vue/compat
). This is for the runtime.