Skip to content

Instantly share code, notes, and snippets.

View guygubaby's full-sized avatar
🍉
Wine & Roses

guygubaby guygubaby

🍉
Wine & Roses
View GitHub Profile
@guygubaby
guygubaby / split-font.ts
Last active October 11, 2025 02:01
Web 中文字体处理
import path from 'node:path'
import process from 'node:process'
import fs from 'node:fs/promises'
import { fontSplit } from 'cn-font-split'
const cwd = process.cwd()
const fontsDir = path.join(cwd, 'src/font/fonts')
const distDir = path.join(cwd, 'src/font/dist')
const genAliFonts = async () => {
@guygubaby
guygubaby / vue-compiler.md
Last active June 18, 2024 02:12
how to use vue compiler to parse vue SFC

A simple plugin to show how to use vue compiler to parse and patch vue SFC

import type { Plugin } from 'vite'
import { MagicString, parse as parseVueSFC } from 'vue/compiler-sfc'
import type { AttributeNode, ElementNode } from '@vue/compiler-core'
import { NodeTypes } from '@vue/compiler-core'

const patchSearch: Plugin = {
    name: 'vite-plugin-patch-wot-design-uni-search',
// doc: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#conditional-types
// extends
type Diff<T, U> = T extends U ? never : T; // Get types from T that are not assignable to U
type Filter<T, U> = T extends U ? T : never; // Get types from T that are assignable to U
type T30 = Diff<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "b" | "d"
type T31 = Filter<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "a" | "c"