24 lines
569 B
TypeScript
24 lines
569 B
TypeScript
import type { Plugin } from 'vite';
|
|
import { config, library } from '@fortawesome/fontawesome-svg-core';
|
|
import { fas } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
/**
|
|
* Vite 插件:配置 FontAwesome
|
|
* 预注册所有图标,避免运行时重复注册
|
|
*/
|
|
export default function fontAwesomePlugin(): Plugin {
|
|
// 在模块加载时配置 FontAwesome
|
|
library.add(fas);
|
|
|
|
return {
|
|
name: 'vite-plugin-fontawesome',
|
|
config() {
|
|
return {
|
|
define: {
|
|
// 确保 FontAwesome 在客户端正确初始化
|
|
},
|
|
};
|
|
},
|
|
};
|
|
}
|