-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvite.config.ts
More file actions
38 lines (35 loc) · 1.03 KB
/
vite.config.ts
File metadata and controls
38 lines (35 loc) · 1.03 KB
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
37
38
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { CJK, literalsCollector } from "vite-plugin-literals-collector";
import { execSync } from "child_process";
import { readdirSync, renameSync } from "fs";
const minifyFont = (target: string[]) => {
if (target.length > 0) {
const text = target.join("").replace(" ", "");
console.log(text, readdirSync("dist/assets"));
const file =
"dist/assets/" +
readdirSync("dist/assets").filter((f) => f.endsWith("otf"))[0];
execSync(`pyftsubset ${file} --text=${text}`);
console.log(readdirSync("dist/assets"));
renameSync(file.replace(".otf", ".subset.otf"), file);
execSync("ls -l dist/assets");
}
};
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
literalsCollector({
include: [/Map\.tsx$/],
target: CJK,
// onResult: minifyFont,
}),
],
resolve: {
alias: {
"@": `${__dirname}/src`,
"@components": `${__dirname}/src/components`,
},
},
});