U
he wei
5 天以前 4c558f4254bf66fc23f471f9e0a34972cd2cc1ab
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
import { defineConfig, loadEnv } from 'vite';
import vue from '@vitejs/plugin-vue';
import Inspect from 'vite-plugin-inspect';
import VueSetupExtend from 'vite-plugin-vue-setup-extend';
import svgSprites from 'rollup-plugin-svg-sprites';
import { fileURLToPath, URL } from 'node:url';
import path from 'node:path';
import commonjs from '@rollup/plugin-commonjs';
 
 
// https://vite.dev/config/
export default defineConfig((_, mode) => {
 
  const env = loadEnv(mode, process.cwd(), '');
  return {
    plugins: [
      vue(),
      Inspect(),
      VueSetupExtend(),
      svgSprites({
        vueComponent: true,
        exclude: ['node_modules/**'],
        symbolId(filePath) {
          const filename = path.basename(filePath);
          return 'icon-' + filename.substring(0, filename.lastIndexOf('.'));
        }
      }),
      commonjs({
        include: ['node_modules/**'],
      }),
    ],
    base: './',
    define: {
      'process.env.MODE': JSON.stringify(env.MODE)
    },
    resolve: {
      alias: {
        '@': fileURLToPath(new URL('./src', import.meta.url))
      },
      extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
    },
    server: {
      host: 'localhost',
      port: 5274
    }
  }
 
});