vbenjs / vue-vben-admin

A modern vue admin panel built with Vue3, Shadcn UI, Vite, TypeScript, and Monorepo. It's fast!
https://www.vben.pro
MIT License
25.48k stars 6.93k forks source link

Bug:无法引入图标精灵 #4221

Open jiuyi919 opened 3 months ago

jiuyi919 commented 3 months ago

Version

Vben Admin V5

Describe the bug?

WechatIMG2291

Reproduction

WechatIMG2292

System Info

Internal server error: Failed to resolve import "virtual:svg-icons-register" from "src/bootstrap.ts". Does the file exist?

Relevant log output

No response

Validations

likui628 commented 3 months ago

@jiuyi919 试一下将配置放到vite内

import path from 'node:path';

import { defineConfig } from '@vben/vite-config';

import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';

export default defineConfig(async () => {
  return {
    application: {},
    vite: {
      plugins: [
        createSvgIconsPlugin({
          // Specify the icon folder to be cached
          customDomId: '__svg__icons__dom__',
          // eslint-disable-next-line n/prefer-global/process
          iconDirs: [path.resolve(process.cwd(), 'src/icons')],
          // Specify symbolId format
          symbolId: 'icon-[dir]-[name]',
        }),
      ],
      server: {
        proxy: {
          '/api': {
            changeOrigin: true,
            rewrite: (path) => path.replace(/^\/api/, ''),
            // mock代理目标地址
            target: 'http://localhost:5320/api',
            ws: true,
          },
        },
      },
    },
  };
});
jiuyi919 commented 3 months ago

尝试过了不可以

Mask-MJ commented 2 months ago

可以尝试使用 unplugin-icons image