forked from gatsbyjs/gatsby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add gatsby-plugin-subfont (gatsbyjs#7850)
* Initial commit for gatsby-plugin-subfont * Add gatsby-node.js * Fill out README * Fill out package.json description
- Loading branch information
1 parent
67fb3ed
commit b4ce940
Showing
12 changed files
with
837 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"presets": [ | ||
["../../.babel-preset.js"] | ||
] | ||
} |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/*.js | ||
!index.js | ||
yarn.lock |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Logs | ||
logs | ||
*.log | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directory | ||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git | ||
node_modules | ||
*.un~ | ||
yarn.lock | ||
src | ||
flow-typed | ||
coverage | ||
decls | ||
examples |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# gatsby-plugin-subfont | ||
|
||
[Subfont](https://github.com/Munter/subfont#readme) is a command line tool that optimizes font delivery for HTML files. | ||
|
||
`gatsby-plugin-subfont` wraps the tool and automatically runs in your site's homepage. | ||
|
||
## Install | ||
|
||
`npm install --save gatsby-plugin-subfont` | ||
|
||
If you want the ability to run font subsetting locally you'l need Python and install fonttools with this command line: | ||
|
||
`pip install fonttools brotli zopfli` | ||
|
||
## How to use | ||
|
||
```javascript | ||
// In your gatsby-config.js | ||
module.exports = { | ||
plugins: [ | ||
`gatsby-plugin-subfont`, | ||
], | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
// noop |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"name": "gatsby-plugin-subfont", | ||
"version": "1.0.0", | ||
"description": "Runs the font delivery optimizing CLI tool subfont on the homepage of your site during the Gatsby build", | ||
"main": "index.js", | ||
"scripts": { | ||
"build": "babel src --out-dir . --ignore **/__tests__", | ||
"watch": "babel -w src --out-dir . --ignore **/__tests__", | ||
"prepare": "cross-env NODE_ENV=production npm run build" | ||
}, | ||
"keywords": [ | ||
"gatsby", | ||
"gatsby-plugin" | ||
], | ||
"author": "Kyle Mathews <[email protected]>", | ||
"bugs": { | ||
"url": "https://github.com/gatsbyjs/gatsby/issues" | ||
}, | ||
"homepage": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-plugin-subfont#readme", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/gatsbyjs/gatsby.git" | ||
}, | ||
"license": "MIT", | ||
"dependencies": { | ||
"@babel/runtime": "^7.0.0", | ||
"subfont": "^3.6.1" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.0.0", | ||
"@babel/core": "^7.0.0", | ||
"cross-env": "^5.0.5" | ||
} | ||
} |
Empty file.
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const path = require(`path`) | ||
const { execSync } = require(`child_process`) | ||
|
||
exports.onPostBuild = ({ store }) => { | ||
const root = path.join(store.getState().program.directory, `public`) | ||
// TODO make this configurable | ||
const urlPaths = [`/`] | ||
const filePaths = urlPaths.reduce( | ||
(accumulator, currentPath) => | ||
`${accumulator} ${path.join(root, currentPath, `index.html`)}`, | ||
`` | ||
) | ||
|
||
const command = `node_modules/.bin/subfont -i --no-recursive --inline-css --root file://${root}${filePaths}` | ||
execSync(command) | ||
} |
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
Oops, something went wrong.