-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: minify svg husky hook (#10560)
and added hooks for *.svg files Co-authored-by: Ward Peeters <[email protected]>
- Loading branch information
Showing
4 changed files
with
44 additions
and
30 deletions.
There are no files selected for viewing
15 changes: 3 additions & 12 deletions
15
docs/blog/2017-11-08-migrate-from-jekyll-to-gatsby/gatsby.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// this file exists because svgo only accepts folders or files, to make this work you'll need to do | ||
// find www examples packages | grep '\\.svg$' | xargs -Iz -n 1 svgo --pretty --indent=2 --config=svgo.yml z | ||
// this only works on bash not inside windows so we create a simple js file that does the globbing for us | ||
const glob = require(`glob`) | ||
const execa = require(`execa`) | ||
const path = require(`path`) | ||
|
||
// list of ignored files because they don't get optimized correctly | ||
const ignoreList = [ | ||
`./docs/blog/2017-11-08-migrate-from-jekyll-to-gatsby/diagram-ci.svg`, | ||
] | ||
|
||
const files = glob.sync(`./**/*.svg`, { | ||
ignore: [`./node_modules/**`].concat(ignoreList), | ||
}) | ||
|
||
const proc = execa( | ||
`./node_modules/.bin/svgo`, | ||
[`--pretty`, `--indent=2`, `--config=svgo.yml`, `--multipass`].concat(files), | ||
{ cwd: path.join(__dirname, `..`) } | ||
) | ||
|
||
proc.stdout.pipe(process.stdout) | ||
proc.stderr.pipe(process.stderr) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.