Skip to content

Commit

Permalink
fix: Generate stylesheet.css
Browse files Browse the repository at this point in the history
  • Loading branch information
prantlf committed Feb 27, 2023
1 parent 5fb7106 commit acf1498
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 192 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
!.gitignore
dist
node_modules
stylesheet.css
8 changes: 7 additions & 1 deletion build/generate.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readdir } from 'node:fs/promises'
import { readdir, readFile, writeFile } from 'node:fs/promises'
import fontfacegen from 'fontfacegen'

// Read all otf font file names
Expand All @@ -15,3 +15,9 @@ for (const fontFile of fontFiles) {
fontfacegen({ source: `dist/${fontFile}`, dest: 'dist', css })
console.log()
}

// Update paths in the complete stylesheet
console.log('stylesheet.css')
let stylesheet = await readFile('stylesheet.css', 'utf8')
stylesheet = stylesheet.replace(/\burl\("([^"]+)"\)/g, 'url("dist/$1")')
await writeFile('stylesheet.css', stylesheet)
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@
"dist"
],
"scripts": {
"prepare": "rm.js -rf \"dist/*\" && mkdir -p dist && cp.js \"*/*.otf\" \"build/css/*.css\" dist && node build/generate",
"prepare": "rm.js -rf \"dist/*\" && mkdir -p dist && cp.js \"*/*.otf\" \"build/css/*.css\" dist && cat.js build/css/*.css > stylesheet.css && node build/generate",
"test": "denolint && node build/test"
},
"devDependencies": {
"@unixcompat/cat.js": "1.0.1",
"@unixcompat/cp.js": "2.0.0",
"@unixcompat/mkdir.js": "1.1.2",
"@unixcompat/rm.js": "2.0.0",
Expand Down
15 changes: 15 additions & 0 deletions pnpm-lock.yaml

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

190 changes: 0 additions & 190 deletions stylesheet.css

This file was deleted.

0 comments on commit acf1498

Please sign in to comment.