Skip to content
This repository has been archived by the owner on Nov 11, 2020. It is now read-only.

Commit

Permalink
Merge pull request #9 from SirPole/master
Browse files Browse the repository at this point in the history
Update google-fonts-plugin to 3.0.0
  • Loading branch information
kennedyrose committed Jan 29, 2019
2 parents ecd1c88 + 45538b9 commit 30c52bc
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 308 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ _optimize
coverage
/*.js
/*.js.map
.idea
!gatsby-config.js

# Temporary
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@
"fs-extra": "^7.0.0",
"get-urls": "^8.0.0",
"globby": "^8.0.1",
"google-fonts-plugin": "^2.0.2",
"google-fonts-plugin": "^3.0.0",
"mkdirp": "^0.5.1",
"object-hash": "^1.3.0"
},
"main": "gatsby-ssr.js",
Expand Down
16 changes: 13 additions & 3 deletions plugins/export/download-css.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
const fs = require('fs')
const path = require('path')
const GoogleFontsWebpackPlugin = require(`google-fonts-plugin`)
const mkdirp = require('mkdirp')

const outputDir = `.cache/google-fonts`

module.exports = async ({
fonts,
Expand All @@ -13,10 +18,15 @@ module.exports = async ({
const googleFontsPlugin = new GoogleFontsWebpackPlugin({
fonts,
formats,
outputDir: `.cache/google-fonts`,
encode: false,
minify: false,
verbose: true,
})
await googleFontsPlugin.make()
}

mkdirp.sync(outputDir)

for (const format of Object.values(googleFontsPlugin.options.formats)) {
let css = await this.requestFontsCSS(format);
fs.writeFileSync(path.join(outputDir, format + '.css'), css)
}
}
Loading

0 comments on commit 30c52bc

Please sign in to comment.