Skip to content

Commit

Permalink
upgrade svgo in gatsby-plugin-sharp
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinjude committed Aug 25, 2022
1 parent b8c2072 commit 74c074d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/gatsby-plugin-sharp/package.json
Expand Up @@ -21,7 +21,7 @@
"probe-image-size": "^7.2.3",
"semver": "^7.3.7",
"sharp": "^0.30.7",
"svgo": "1.3.2"
"svgo": "2.8.0"
},
"devDependencies": {
"@babel/cli": "^7.15.4",
Expand Down
11 changes: 6 additions & 5 deletions packages/gatsby-plugin-sharp/src/trace-svg.js
Expand Up @@ -72,16 +72,17 @@ exports.notMemoizedPrepareTraceSVGInputFile = async ({
}

const optimize = svg => {
const SVGO = require(`svgo`)
const svgo = new SVGO({
const { optimize } = require(`svgo`)
const svgo = optimize(svg, {
multipass: true,
floatPrecision: 0,
plugins: [
{
removeViewBox: false,
name: `removeViewBox`,
},
{
addAttributesToSVGElement: {
name: `addAttributesToSVGElement`,
params: {
attributes: [
{
preserveAspectRatio: `none`,
Expand All @@ -91,7 +92,7 @@ const optimize = svg => {
},
],
})
return svgo.optimize(svg).then(({ data }) => data)
return svgo.data
}

exports.notMemoizedtraceSVG = async ({ file, args, fileArgs, reporter }) => {
Expand Down
26 changes: 13 additions & 13 deletions yarn.lock
Expand Up @@ -23629,19 +23629,7 @@ svgo@1.3.2, svgo@^1.0.0:
unquote "~1.1.1"
util.promisify "~1.0.0"

svgo@^0.7.2:
version "0.7.2"
resolved "https://registry.yarnpkg.com/svgo/-/svgo-0.7.2.tgz#9f5772413952135c6fefbf40afe6a4faa88b4bb5"
dependencies:
coa "~1.0.1"
colors "~1.1.2"
csso "~2.3.1"
js-yaml "~3.7.0"
mkdirp "~0.5.1"
sax "~1.2.1"
whet.extend "~0.9.9"

svgo@^2.3.0, svgo@^2.8.0:
svgo@2.8.0, svgo@^2.3.0, svgo@^2.8.0:
version "2.8.0"
resolved "https://registry.yarnpkg.com/svgo/-/svgo-2.8.0.tgz#4ff80cce6710dc2795f0c7c74101e6764cfccd24"
integrity sha512-+N/Q9kV1+F+UeWYoSiULYo4xYSDQlTgb+ayMobAXPwMnLvop7oxKMo9OzIrX5x3eS4L4f2UHhc9axXwY8DpChg==
Expand All @@ -23654,6 +23642,18 @@ svgo@^2.3.0, svgo@^2.8.0:
picocolors "^1.0.0"
stable "^0.1.8"

svgo@^0.7.2:
version "0.7.2"
resolved "https://registry.yarnpkg.com/svgo/-/svgo-0.7.2.tgz#9f5772413952135c6fefbf40afe6a4faa88b4bb5"
dependencies:
coa "~1.0.1"
colors "~1.1.2"
csso "~2.3.1"
js-yaml "~3.7.0"
mkdirp "~0.5.1"
sax "~1.2.1"
whet.extend "~0.9.9"

sw-precache@^5.2.0:
version "5.2.1"
resolved "https://registry.yarnpkg.com/sw-precache/-/sw-precache-5.2.1.tgz#06134f319eec68f3b9583ce9a7036b1c119f7179"
Expand Down

0 comments on commit 74c074d

Please sign in to comment.