|
@@ -0,0 +1,90 @@
|
|
|
+/// <reference types="vitest" />
|
|
|
+
|
|
|
+import path from 'node:path'
|
|
|
+import { defineConfig } from 'vite'
|
|
|
+import Vue from '@vitejs/plugin-vue'
|
|
|
+import Pages from 'vite-plugin-pages'
|
|
|
+import Components from 'unplugin-vue-components/vite'
|
|
|
+
|
|
|
+import AutoImport from 'unplugin-auto-import/vite'
|
|
|
+import WindiCSS from 'vite-plugin-windicss'
|
|
|
+import VueMacros from 'unplugin-vue-macros/vite'
|
|
|
+import { VantResolver } from 'unplugin-vue-components/resolvers'
|
|
|
+import legacyPlugin from '@vitejs/plugin-legacy'
|
|
|
+export default defineConfig({
|
|
|
+ base: '',
|
|
|
+ resolve: {
|
|
|
+ alias: {
|
|
|
+ '~/': `${path.resolve(__dirname, 'src')}/`,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ server: {
|
|
|
+ hmr: { overlay: false }, // 禁用或配置 HMR 连接 设置 server.hmr.overlay 为 false 可以禁用服务器错误遮罩层
|
|
|
+ },
|
|
|
+ plugins: [
|
|
|
+ legacyPlugin({
|
|
|
+ targets: ['chrome 52'], // 需要兼容的目标列表,可以设置多个
|
|
|
+ additionalLegacyPolyfills: ['regenerator-runtime/runtime'] // 面向IE11时需要此插件
|
|
|
+ }),
|
|
|
+
|
|
|
+ VueMacros({
|
|
|
+ defineOptions: false,
|
|
|
+ defineModels: false,
|
|
|
+ plugins: {
|
|
|
+ vue: Vue({
|
|
|
+ script: {
|
|
|
+ propsDestructure: true,
|
|
|
+ defineModel: true,
|
|
|
+ },
|
|
|
+ }),
|
|
|
+ },
|
|
|
+ }),
|
|
|
+
|
|
|
+ // https://github.com/hannoeru/vite-plugin-pages
|
|
|
+ Pages(
|
|
|
+ {
|
|
|
+ dirs: 'src/pages',
|
|
|
+ exclude: ['**/components/*.vue'],
|
|
|
+ },
|
|
|
+ ),
|
|
|
+
|
|
|
+ // https://github.com/antfu/unplugin-auto-import
|
|
|
+ AutoImport({
|
|
|
+ imports: [
|
|
|
+ 'vue',
|
|
|
+ 'vue/macros',
|
|
|
+ 'vue-router',
|
|
|
+ '@vueuse/core',
|
|
|
+ ],
|
|
|
+ dts: true,
|
|
|
+ dirs: [
|
|
|
+ './src/composables',
|
|
|
+ './src/request',
|
|
|
+ './src/utils',
|
|
|
+ ],
|
|
|
+ vueTemplate: true,
|
|
|
+ resolvers: [
|
|
|
+
|
|
|
+ ],
|
|
|
+ }),
|
|
|
+
|
|
|
+ // https://github.com/antfu/vite-plugin-components
|
|
|
+ Components({
|
|
|
+ dirs: ['src/components/'],
|
|
|
+ // allow auto load markdown components under `./src/components/`
|
|
|
+ extensions: ['vue', 'md'],
|
|
|
+ // allow auto import and register components used in markdown
|
|
|
+ include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
|
|
|
+ resolvers: [VantResolver()],
|
|
|
+ }),
|
|
|
+
|
|
|
+ // https://github.com/antfu/unocss
|
|
|
+ // see uno.config.ts for config
|
|
|
+ WindiCSS(),
|
|
|
+ ],
|
|
|
+
|
|
|
+ // https://github.com/vitest-dev/vitest
|
|
|
+ test: {
|
|
|
+ environment: 'jsdom',
|
|
|
+ },
|
|
|
+})
|