u
This commit is contained in:
1 parent
68e0785ec6
commit
57c0d98f11
189 files changed
+34329
No files matched your search
@@ -0,0 +1,35 @@
|
||||
import process from "node:process";
|
||||
import path from "node:path";
|
||||
import unocss from "@unocss/vite";
|
||||
import presetIcons from "@unocss/preset-icons";
|
||||
import { FileSystemIconLoader } from "@iconify/utils/lib/loader/node-loaders";
|
||||
|
||||
export function setupUnocss(viteEnv: Env.ImportMeta) {
|
||||
const { VITE_ICON_PREFIX, VITE_ICON_LOCAL_PREFIX } = viteEnv;
|
||||
|
||||
const localIconPath = path.join(process.cwd(), "src/assets/svg-icon");
|
||||
|
||||
/** The name of the local icon collection */
|
||||
const collectionName = VITE_ICON_LOCAL_PREFIX.replace(
|
||||
`${VITE_ICON_PREFIX}-`,
|
||||
""
|
||||
);
|
||||
|
||||
return unocss({
|
||||
presets: [
|
||||
presetIcons({
|
||||
prefix: `${VITE_ICON_PREFIX}-`,
|
||||
scale: 1,
|
||||
extraProperties: {
|
||||
display: "inline-block",
|
||||
},
|
||||
collections: {
|
||||
[collectionName]: FileSystemIconLoader(localIconPath, (svg) =>
|
||||
svg.replace(/^<svg\s/, '<svg width="1em" height="1em" ')
|
||||
),
|
||||
},
|
||||
warn: true,
|
||||
}),
|
||||
],
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user