Skip to content

Commit

Permalink
read woff2 font links from the css files instead of static dir
Browse files Browse the repository at this point in the history
  • Loading branch information
phaleth authored and terrablue committed May 13, 2024
1 parent 7e1dc22 commit 064ac7c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/primate/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,10 @@ export default async (log, root, config) => {
await Promise.all((await source.collect(filter)).map(async abs_path => {
const debased = abs_path.debase(this.root).path.slice(1);
const rel_path = FS.File.join(directory, abs_path.debase(source));
if (directory.path === client_location && rel_path.path.endsWith(".woff2")) {
const needle = location.static, index = rel_path.path.indexOf(needle);
this.fonts.push(rel_path.path.slice(index + needle.length));
if (directory.path === client_location && rel_path.path.endsWith(".css")) {
const contents = await abs_path.text();
const font_regex = /@font-face\s*\{.+?url\("(.+?\.woff2)"\).+?\}/gus;
this.fonts.push(...[...contents.matchAll(font_regex)].map(match => match[1]));
}
const target = await target_base.join(rel_path.debase(directory));
await target.directory.create();
Expand Down

0 comments on commit 064ac7c

Please sign in to comment.