UNPKG

gatsby-plugin-prefetch-google-fonts

Version:

A Gatsby plugin to download and prefetch [Google Fonts](https://fonts.google.com/). Can increase performance as opposed to loading webfonts from Google's external stylesheet.

49 lines (40 loc) 1.5 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); var GoogleFontsWebpackPlugin = require("google-fonts-plugin"); var path = require("path"); module.exports = /*#__PURE__*/ function () { var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/ _regenerator.default.mark(function _callee(_ref, config) { var fonts, _ref$formats, formats, googleFontsPlugin; return _regenerator.default.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: fonts = _ref.fonts, _ref$formats = _ref.formats, formats = _ref$formats === void 0 ? [//`eot`, "woff2", "woff"] : _ref$formats; googleFontsPlugin = new GoogleFontsWebpackPlugin({ fonts: fonts, formats: formats, outputDir: path.join(".cache/google-fonts", config.pathPrefix), encode: false, minify: false, verbose: true }); _context.next = 4; return googleFontsPlugin.make(); case 4: case "end": return _context.stop(); } } }, _callee, this); })); return function (_x, _x2) { return _ref2.apply(this, arguments); }; }();