|
@@ -1,6 +1,19 @@
|
|
|
import { fileURLToPath, URL } from "node:url";
|
|
|
import { defineConfig } from "vitepress";
|
|
|
import VueI18nPlugin from "@intlify/unplugin-vue-i18n/vite";
|
|
|
+import Icons from "unplugin-icons/vite";
|
|
|
+// import Components from 'unplugin-vue-components/vite'
|
|
|
+import { FileSystemIconLoader } from "unplugin-icons/loaders";
|
|
|
+import {
|
|
|
+ SVG,
|
|
|
+ cleanupSVG,
|
|
|
+ parseColors,
|
|
|
+ runSVGO,
|
|
|
+ deOptimisePaths,
|
|
|
+ importDirectory,
|
|
|
+} from "@iconify/tools";
|
|
|
+import { compareColors, stringToColor } from "@iconify/utils/lib/colors";
|
|
|
+
|
|
|
|
|
|
// https://vitepress.dev/reference/site-config
|
|
|
export default defineConfig({
|
|
@@ -16,12 +29,68 @@ export default defineConfig({
|
|
|
vite: {
|
|
|
publicDir: "../public",
|
|
|
plugins: [
|
|
|
- /* ... */
|
|
|
VueI18nPlugin({
|
|
|
/* options */
|
|
|
// locale messages resource pre-compile option
|
|
|
// include: resolve(dirname(fileURLToPath(import.meta.url)), './path/to/src/locales/**'),
|
|
|
}),
|
|
|
+ Icons({
|
|
|
+ compiler: "vue3",
|
|
|
+ customCollections: {
|
|
|
+ "ccrbi-plain": FileSystemIconLoader(
|
|
|
+ "assets/icons/plain",
|
|
|
+ async (svgStr) => {
|
|
|
+ const svg = new SVG(svgStr);
|
|
|
+ cleanupSVG(svg);
|
|
|
+
|
|
|
+
|
|
|
+ parseColors(svg, {
|
|
|
+ defaultColor: "currentColor",
|
|
|
+ callback: (attr, colorStr, color) => {
|
|
|
+ // console.log('Color:', colorStr, color);
|
|
|
+ // 普通图标
|
|
|
+ return "currentColor";
|
|
|
+
|
|
|
+ // Change black to 'currentColor'
|
|
|
+ // const blackColor = stringToColor("black");
|
|
|
+ // if (color && compareColors(color, blackColor!)) {
|
|
|
+ // return "currentColor";
|
|
|
+ // }
|
|
|
+
|
|
|
+ // switch (color?.type) {
|
|
|
+ // case "none":
|
|
|
+ // case "current":
|
|
|
+ // return color;
|
|
|
+ // }
|
|
|
+ // throw new Error(
|
|
|
+ // `Unexpected color "${colorStr}" in attribute ${attr}`
|
|
|
+ // );
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ // Optimise, but do not change shapes because they are animated
|
|
|
+ runSVGO(svg, {
|
|
|
+ keepShapes: true,
|
|
|
+ });
|
|
|
+ return svg.toMinifiedString({});
|
|
|
+ }
|
|
|
+ ),
|
|
|
+ "ccrbi-colored": FileSystemIconLoader(
|
|
|
+ "assets/icons/colored",
|
|
|
+ async (svgStr) => {
|
|
|
+ const svg = new SVG(svgStr);
|
|
|
+ cleanupSVG(svg);
|
|
|
+
|
|
|
+
|
|
|
+ // Optimise, but do not change shapes because they are animated
|
|
|
+ runSVGO(svg, {
|
|
|
+ keepShapes: true,
|
|
|
+ });
|
|
|
+ return svg.toMinifiedString({});
|
|
|
+ }
|
|
|
+ ),
|
|
|
+ },
|
|
|
+ }),
|
|
|
],
|
|
|
resolve: {
|
|
|
alias: [
|