Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: optimize font family #38

Merged
merged 1 commit into from
Jun 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"eslint-plugin-prettier": "^4.2.1",
"prettier": "^2.7.1",
"typescript": "^4.6.4",
"unplugin-fonts": "^1.0.3",
"vite": "^3.1.8",
"vite-plugin-purge-icons": "^0.9.1"
},
Expand Down
88 changes: 88 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'unfonts.css'
import "./assets/colors/white.css";
import "./assets/colors/light.css";
import "./assets/colors/dark.css";
Expand Down
10 changes: 5 additions & 5 deletions src/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,9 @@ body {
color: var(--color-text);
font-weight: 400;
font-size: 14px;
font-family: "Menlo", "Meslo LG", monospace, "arial", "Georgia", sans-serif;
font-family: "Menlo", "Meslo LG", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
"Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol",
"Noto Color Emoji";
line-height: 1.725;
text-rendering: geometricPrecision;
flex: 1;
Expand Down Expand Up @@ -1736,7 +1738,6 @@ article a {
color: var(--color-background);
font-weight: 400;
font-size: 11.200000000000001px;
font-family: monospace, "arial", "Georgia", "serif";
line-height: 1.725;
text-rendering: geometricPrecision;
text-align: center;
Expand Down Expand Up @@ -1873,7 +1874,6 @@ article a {
/*友链页面样式开始*/
#links li {
list-style: none;
font-family: "Menlo", "Meslo LG", monospace, monospace, "arial", "Georgia", sans-serif;
color: var(--color-text);
}

Expand Down Expand Up @@ -2354,8 +2354,8 @@ pre {
border: 1px dotted #666;
border-radius: 4px;
font-size: 13px;
font-family: "Menlo", "Meslo LG", monospace, monospace, "arial", "Georgia", sans-serif;
line-height: 22px;
font-family: inherit;
-webkit-border-radius: 4px;
}

Expand All @@ -2369,6 +2369,7 @@ code {
padding: 0 5px;
border: 1px dotted #666;
border-radius: 2px;
font-family: inherit;
-webkit-border-radius: 2px;
}

Expand All @@ -2377,7 +2378,6 @@ code {
margin: 0;
border-radius: 4px;
background: #212326;
font-family: "Menlo", "Meslo LG", monospace, monospace, "arial", "Georgia", sans-serif;
-webkit-border-radius: 4px;
}

Expand Down
4 changes: 2 additions & 2 deletions templates/assets/dist/main.iife.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion templates/assets/dist/style.css

Large diffs are not rendered by default.

56 changes: 51 additions & 5 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,65 @@ import { defineConfig } from "vite";
import { fileURLToPath } from "url";
import path from "path";
// vite.config.js
import PurgeIcons from 'vite-plugin-purge-icons'
import PurgeIcons from "vite-plugin-purge-icons";
import Unfonts from "unplugin-fonts/vite";

export default defineConfig({
plugins: [
PurgeIcons({
content: [
'./templates/*.html',
],
})
content: ["./templates/*.html"],
}),
Unfonts({
custom: {
/**
* Fonts families lists
*/
families: [
{
/**
* Name of the font family.
*/
name: "Meslo LG",
/**
* Local name of the font. Used to add `src: local()` to `@font-rule`.
*/
local: "Meslo LG S",
/**
* Regex(es) of font files to import. The names of the files will
* predicate the `font-style` and `font-weight` values of the `@font-rule`'s.
*/
src: "./src/assets/fonts/meslo-LG/MesloLGS-Regular.ttf",
},
],

/**
* Defines the default `font-display` value used for the generated
* `@font-rule` classes.
*/
display: "auto",

/**
* Using `<link rel="preload">` will trigger a request for the WebFont
* early in the critical rendering path, without having to wait for the
* CSSOM to be created.
*/
preload: true,

/**
* Using `<link rel="prefetch">` is intended for prefetching resources
* that will be used in the next navigation/page load
* (e.g. when you go to the next page)
*
* Note: this can not be used with `preload`
*/
prefetch: false,
},
}),
],
build: {
outDir: fileURLToPath(new URL("./templates/assets/dist", import.meta.url)),
emptyOutDir: true,

lib: {
entry: path.resolve(__dirname, "src/main.ts"),
name: "main",
Expand Down