tanghaolin
6 天以前 dfd5d14c2e0b703845953765e1f125f8c93537a8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { fileURLToPath, URL } from 'node:url';
 
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
import autoprefixer from 'autoprefixer';
import { CodeInspectorPlugin } from 'code-inspector-plugin';
import { visualizer } from 'rollup-plugin-visualizer';
import tailwindcss from 'tailwindcss';
import AutoImport from 'unplugin-auto-import/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
import Components from 'unplugin-vue-components/vite';
import { defineConfig } from 'vite';
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => ({
    plugins: [
        CodeInspectorPlugin({
            bundler: 'vite',
            hotKeys: ['shiftKey'],
        }),
        vue(),
        vueJsx(),
        AutoImport({
            resolvers: [
                ElementPlusResolver({
                    importStyle: 'sass',
                }),
            ],
            imports: ['vue', '@vueuse/core', 'vue-router', 'pinia'],
        }),
 
        Components({
            resolvers: [
                ElementPlusResolver({
                    importStyle: 'sass',
                }),
            ],
        }),
        visualizer({
            gzipSize: true,
            brotliSize: true,
            emitFile: false,
            open: false, //如果存在本地服务端口,将在打包后自动展示
        }),
    ],
    base: './',
    server: {
        host: '0.0.0.0',
        port: 5680,
    },
 
    resolve: {
        alias: {
            '@': fileURLToPath(new URL('./src', import.meta.url)),
        },
    },
    css: {
        preprocessorOptions: {
            css: { charset: false },
            scss: {
                additionalData: '@use "@/styles/element.scss";',
                silenceDeprecations: ['legacy-js-api'],
            },
        },
 
        postcss: {
            plugins: [tailwindcss, autoprefixer],
        },
    },
}));