Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions packages/gatsby-plugin-manifest/package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
{
"name": "gatsby-plugin-manifest",
"description": "Gatsby plugin which adds a manifest.webmanifest to make sites progressive web apps",
"version": "3.3.0-next.1",
"version": "3.3.0",
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
"bugs": {
"url": "https://github.com/gatsbyjs/gatsby/issues"
},
"dependencies": {
"@babel/runtime": "^7.12.5",
"gatsby-core-utils": "^2.3.0-next.1",
"gatsby-plugin-utils": "^1.3.0-next.1",
"semver": "^7.3.2",
"gatsby-core-utils": "^2.3.0",
"gatsby-plugin-utils": "^1.3.0",
"semver": "^7.3.2"
},
"optionalDependencies": {
"sharp": "^0.28.0"
},
"devDependencies": {
"@babel/cli": "^7.12.1",
"@babel/core": "^7.12.3",
"babel-preset-gatsby-package": "^1.3.0-next.1",
"cross-env": "^7.0.3"
"babel-preset-gatsby-package": "^1.3.0",
"cross-env": "^7.0.3",
"sharp": "^0.28.0"
},
"homepage": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-plugin-manifest#readme",
"keywords": [
Expand All @@ -32,7 +35,7 @@
"license": "MIT",
"main": "index.js",
"peerDependencies": {
"gatsby": "^3.0.0-next.0"
"gatsby": "^3.0.0"
},
"repository": {
"type": "git",
Expand Down
15 changes: 11 additions & 4 deletions packages/gatsby-plugin-manifest/src/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import * as fs from "fs"
import * as path from "path"
import sharp from "./safe-sharp"
import { createContentDigest, cpuCoreCount, slash } from "gatsby-core-utils"
import { defaultIcons, addDigestToPath, favicons } from "./common"
import { doesIconExist } from "./node-helpers"

import pluginOptionsSchema from "./pluginOptionsSchema"

sharp.simd(true)
let sharp
function getSharp() {
// import sharp lazily
if (!sharp) {
sharp = require(`./safe-sharp`)
sharp.simd(true)
}
return sharp
}

// Handle Sharp's concurrency based on the Gatsby CPU count
// See: http://sharp.pixelplumbing.com/en/stable/api-utility/#concurrency
Expand All @@ -30,7 +37,7 @@ async function generateIcon(icon, srcIcon) {
// Sharp accept density from 1 to 2400
const density = Math.min(2400, Math.max(1, size))

return sharp(srcIcon, { density })
return getSharp()(srcIcon, { density })
.resize({
width: size,
height: size,
Expand Down Expand Up @@ -195,7 +202,7 @@ const makeManifest = async ({
)
}

const sharpIcon = sharp(icon)
const sharpIcon = getSharp()(icon)

const metadata = await sharpIcon.metadata()

Expand Down