-
Notifications
You must be signed in to change notification settings - Fork 1
/
iconfont.config.mjs
36 lines (33 loc) · 1.24 KB
/
iconfont.config.mjs
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
import path from "path";
import fs from "fs";
import prettier from "prettier";
import { getSvgTSReactComponentContent, toBigCamelCase } from "./src/index.js";
import { fileURLToPath } from "url";
const _dirname = path.dirname(fileURLToPath(import.meta.url));
const formatCode = (code, parser) => {
return prettier.format(code, { ...JSON.parse(fs.readFileSync(path.resolve(_dirname, ".prettierrc"))).toString(), parser });
};
/** @type {import('./src/index.js').Config} */
export default {
title: "Iconfont Preview",
resourceDir: "client/src/svg",
output: {
font: {
dir: "client/src/font",
name: "iconfont",
format: formatCode,
},
component: {
dir: "client/src/font/components",
fileFullName: fileName => `${toBigCamelCase(fileName.replace(/_oc$/, "_OC"))}.tsx`,
name: fileName => toBigCamelCase(fileName.replace(/_oc$/, "_OC")),
content: (...args) => formatCode(getSvgTSReactComponentContent(...args), "typescript"),
clearColor: fileName => !fileName.endsWith("_oc"),
},
},
scan: {
rootDir: "client",
includes: ["src/**/*.{ts,tsx,js,jsx}"],
excludes: ["src/font/**/*", "**/*.d.ts"],
},
};