2024-12-19 13:51:07 +08:00
|
|
|
import { defineConfig } from 'vite'
|
|
|
|
import vue from '@vitejs/plugin-vue'
|
|
|
|
import vueJsx from '@vitejs/plugin-vue-jsx'
|
|
|
|
|
|
|
|
import vue2 from '@vitejs/plugin-vue2'
|
|
|
|
import vue2Jsx from '@vitejs/plugin-vue2-jsx'
|
2025-05-19 10:55:41 +08:00
|
|
|
import { isVue2, isVue3, version } from 'vue-demi'
|
2024-12-19 13:51:07 +08:00
|
|
|
import path from 'node:path'
|
|
|
|
import { createRequire } from 'node:module'
|
|
|
|
|
|
|
|
const resolve = (str: string) => {
|
|
|
|
return path.resolve(__dirname, str)
|
|
|
|
}
|
2025-05-19 10:55:41 +08:00
|
|
|
console.log('vue', version)
|
2024-12-19 13:51:07 +08:00
|
|
|
|
|
|
|
function getV2Compiler() {
|
|
|
|
const req = createRequire(import.meta.url);
|
|
|
|
const rt = req.resolve("./node_modules/vue2/compiler-sfc");
|
|
|
|
console.log(rt);
|
|
|
|
const c = req(rt)
|
|
|
|
console.log(c);
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
// https://vite.dev/config/
|
|
|
|
export default defineConfig({
|
2025-05-19 10:55:41 +08:00
|
|
|
plugins: isVue3 ?
|
|
|
|
[vue(), vueJsx()] :
|
2025-05-19 11:25:59 +08:00
|
|
|
[vue2({ compiler: getV2Compiler() }), vue2Jsx()],
|
2025-05-19 10:55:41 +08:00
|
|
|
resolve: {
|
|
|
|
alias: {
|
2024-12-19 13:51:07 +08:00
|
|
|
vue: isVue2 ? resolve('./node_modules/vue2') : resolve('./node_modules/vue'),
|
|
|
|
}
|
|
|
|
},
|
|
|
|
optimizeDeps: {
|
|
|
|
exclude: ['vue-demi']
|
2025-05-19 10:55:41 +08:00
|
|
|
}
|
2024-12-19 13:51:07 +08:00
|
|
|
})
|