Skip to content

Commit

Permalink
Test css build #69 (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
qrac committed Aug 27, 2023
1 parent 44fbfa7 commit 20cbafe
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/yakuhanjp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"scripts": {
"build": "npm run clean && npm run build:src",
"build:src": "tsx ./src/build.ts",
"build:src": "vite build",
"clean": "rimraf ./dist",
"prepublishOnly": "npm run build"
}
Expand Down
104 changes: 104 additions & 0 deletions packages/yakuhanjp/src/yakuhanjp.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/* Yaku Han JP (OFL-1.1 AND MIT) by Qrac */
/* Type: YakuHanJP - Based on Noto Sans JP */
/*@font-face {
font-family: "YakuHanJP";
font-style: normal;
font-weight: 100;
font-display: swap;
src: url("core/YakuHanJP/export/woff2/YakuHanJP-Thin.woff2") format("woff2");
unicode-range: U+3001, U+3002, U+3008, U+3009, U+300a, U+300b, U+300c, U+300d,
U+300e, U+300f, U+3010, U+3011, U+3014, U+3015, U+30fb, U+ff01, U+ff08,
U+ff09, U+ff1a, U+ff1b, U+ff1f, U+ff3b, U+ff3d, U+ff5b, U+ff5d;
}
@font-face {
font-family: "YakuHanJP";
font-style: normal;
font-weight: 200;
font-display: swap;
src: url("core/YakuHanJP/export/woff2/YakuHanJP-ExtraLight.woff2")
format("woff2");
unicode-range: U+3001, U+3002, U+3008, U+3009, U+300a, U+300b, U+300c, U+300d,
U+300e, U+300f, U+3010, U+3011, U+3014, U+3015, U+30fb, U+ff01, U+ff08,
U+ff09, U+ff1a, U+ff1b, U+ff1f, U+ff3b, U+ff3d, U+ff5b, U+ff5d;
}
@font-face {
font-family: "YakuHanJP";
font-style: normal;
font-weight: 300;
font-display: swap;
src: url("core/YakuHanJP/export/woff2/YakuHanJP-Light.woff2") format("woff2");
unicode-range: U+3001, U+3002, U+3008, U+3009, U+300a, U+300b, U+300c, U+300d,
U+300e, U+300f, U+3010, U+3011, U+3014, U+3015, U+30fb, U+ff01, U+ff08,
U+ff09, U+ff1a, U+ff1b, U+ff1f, U+ff3b, U+ff3d, U+ff5b, U+ff5d;
}
@font-face {
font-family: "YakuHanJP";
font-style: normal;
font-weight: 400;
font-display: swap;
src: url("core/YakuHanJP/export/woff2/YakuHanJP-Regular.woff2")
format("woff2");
unicode-range: U+3001, U+3002, U+3008, U+3009, U+300a, U+300b, U+300c, U+300d,
U+300e, U+300f, U+3010, U+3011, U+3014, U+3015, U+30fb, U+ff01, U+ff08,
U+ff09, U+ff1a, U+ff1b, U+ff1f, U+ff3b, U+ff3d, U+ff5b, U+ff5d;
}
@font-face {
font-family: "YakuHanJP";
font-style: normal;
font-weight: 500;
font-display: swap;
src: url("core/YakuHanJP/export/woff2/YakuHanJP-Medium.woff2") format("woff2");
unicode-range: U+3001, U+3002, U+3008, U+3009, U+300a, U+300b, U+300c, U+300d,
U+300e, U+300f, U+3010, U+3011, U+3014, U+3015, U+30fb, U+ff01, U+ff08,
U+ff09, U+ff1a, U+ff1b, U+ff1f, U+ff3b, U+ff3d, U+ff5b, U+ff5d;
}
@font-face {
font-family: "YakuHanJP";
font-style: normal;
font-weight: 600;
font-display: swap;
src: url("core/YakuHanJP/export/woff2/YakuHanJP-SemiBold.woff2")
format("woff2");
unicode-range: U+3001, U+3002, U+3008, U+3009, U+300a, U+300b, U+300c, U+300d,
U+300e, U+300f, U+3010, U+3011, U+3014, U+3015, U+30fb, U+ff01, U+ff08,
U+ff09, U+ff1a, U+ff1b, U+ff1f, U+ff3b, U+ff3d, U+ff5b, U+ff5d;
}
@font-face {
font-family: "YakuHanJP";
font-style: normal;
font-weight: 700;
font-display: swap;
src: url("core/YakuHanJP/export/woff2/YakuHanJP-Bold.woff2") format("woff2");
unicode-range: U+3001, U+3002, U+3008, U+3009, U+300a, U+300b, U+300c, U+300d,
U+300e, U+300f, U+3010, U+3011, U+3014, U+3015, U+30fb, U+ff01, U+ff08,
U+ff09, U+ff1a, U+ff1b, U+ff1f, U+ff3b, U+ff3d, U+ff5b, U+ff5d;
}
@font-face {
font-family: "YakuHanJP";
font-style: normal;
font-weight: 800;
font-display: swap;
src: url("core/YakuHanJP/export/woff2/YakuHanJP-ExtraBold.woff2")
format("woff2");
unicode-range: U+3001, U+3002, U+3008, U+3009, U+300a, U+300b, U+300c, U+300d,
U+300e, U+300f, U+3010, U+3011, U+3014, U+3015, U+30fb, U+ff01, U+ff08,
U+ff09, U+ff1a, U+ff1b, U+ff1f, U+ff3b, U+ff3d, U+ff5b, U+ff5d;
}*/

@font-face {
font-family: "YakuHanJP";
font-style: normal;
font-weight: 900;
font-display: swap;
src: url("core/YakuHanJP/export/woff2/YakuHanJP-Black.woff2") format("woff2");
unicode-range: U+3001, U+3002, U+3008, U+3009, U+300a, U+300b, U+300c, U+300d,
U+300e, U+300f, U+3010, U+3011, U+3014, U+3015, U+30fb, U+ff01, U+ff08,
U+ff09, U+ff1a, U+ff1b, U+ff1f, U+ff3b, U+ff3d, U+ff5b, U+ff5d;
}
40 changes: 40 additions & 0 deletions packages/yakuhanjp/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import type { PreRenderedAsset } from "rollup"
import path from "node:path"
import { defineConfig } from "vite"
import banner from "vite-plugin-banner"

import pkg from "./package.json"
import pjt from "./project.json"

function resolveOutput(chunkInfo: PreRenderedAsset) {
const filePath = chunkInfo.name || ""
const fileExt = path.extname(filePath)

if (fileExt === ".woff2") {
const fontName = filePath.split("-")[0]
return path.join("fonts", fontName, "[name]" + ".[ext]")
}
return path.join("css", "[name]" + ".[ext]")
}

export default defineConfig({
base: "./",
build: {
assetsInlineLimit: 0,
rollupOptions: {
input: ["./src/yakuhanjp.css"],
output: {
assetFileNames: (chunkInfo) => resolveOutput(chunkInfo),
},
},
},
plugins: [
banner((filePath: string) => {
const fileName = path.basename(filePath).split(".")[0]
const font = pjt.fonts.find((item) => item.dist.name === fileName)
const pkgStr = `${pjt.name} v${pkg.version} ${pkg.license} by ${pkg.author.name}`
const typeStr = `Type: ${font?.name} - Based on ${font?.base}`
return `${pkgStr} | ${typeStr}`
}),
],
})

0 comments on commit 20cbafe

Please sign in to comment.