-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gatsby-plugin-subfont): Make async, add configurable opti… (#21768)
Add gatsby-plugin-subfont configurable option feature Update subfont version Co-authored-by: Ward Peeters <ward@coding-tech.com>
- Loading branch information
1 parent
a49df73
commit 06034f2
Showing
3 changed files
with
52 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
const path = require(`path`) | ||
const { execSync } = require(`child_process`) | ||
const shellescape = require(`shell-escape`) | ||
const subfont = require(`subfont`) | ||
|
||
exports.onPostBuild = ({ store }) => { | ||
exports.onPostBuild = async ({ store, reporter }, options) => { | ||
const root = path.join(store.getState().program.directory, `public`) | ||
// TODO make this configurable | ||
const urlPaths = [`/`] | ||
const baseArgs = [ | ||
`node_modules/.bin/subfont`, | ||
`-i`, | ||
`--no-recursive`, | ||
`--inline-css`, | ||
`--root`, | ||
`file://${root}`, | ||
] | ||
const args = baseArgs.concat( | ||
urlPaths.map(currentPath => path.join(root, currentPath, `index.html`)) | ||
const subfontConsole = { | ||
log: reporter.info, | ||
warn: reporter.warn, | ||
error: reporter.error, | ||
} | ||
|
||
await subfont( | ||
{ | ||
root, | ||
inPlace: true, | ||
inlineCss: true, | ||
silent: true, | ||
inputFiles: [path.join(root, `index.html`)], | ||
...options, | ||
}, | ||
subfontConsole | ||
) | ||
const command = shellescape(args) | ||
execSync(command) | ||
} |