diff --git a/docs/blog/2017-11-08-migrate-from-jekyll-to-gatsby/gatsby.svg b/docs/blog/2017-11-08-migrate-from-jekyll-to-gatsby/gatsby.svg index fa7e3b8860c67..51b5741111af4 100644 --- a/docs/blog/2017-11-08-migrate-from-jekyll-to-gatsby/gatsby.svg +++ b/docs/blog/2017-11-08-migrate-from-jekyll-to-gatsby/gatsby.svg @@ -1,12 +1,3 @@ - - - - gatsby - Created with Sketch. - - - - - - - \ No newline at end of file + + + diff --git a/package.json b/package.json index 594f1e1866794..b0509b3150307 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,10 @@ "*.{md,css,scss,yaml,yml}": [ "prettier --write", "git add" + ], + "*.svg": [ + "svgo --pretty --indent=2 --config=svgo.yml --multipass", + "git add" ] }, "husky": { @@ -61,10 +65,10 @@ "scripts": { "bootstrap": "npm-run-all -s check-versions lerna-prepare", "check-versions": "babel-node scripts/check-versions.js", - "format": "npm run format:code && npm run format:other", + "format": "npm run format:code && npm run format:other && npm run format:svg", "format:other": "npm run prettier -- --write", "format:code": "npm run lint:code -- --fix", - "format-svg": "find www examples packages | grep '\\.svg$' | xargs -Iz -n 1 svgo --pretty --indent=2 --config=svgo.yml z", + "format:svg": "node scripts/format-svg.js", "hooks:uninstall": "node node_modules/husky/husky.js uninstall", "hooks:install": "node node_modules/husky/husky.js install", "jest": "jest", diff --git a/scripts/format-svg.js b/scripts/format-svg.js new file mode 100644 index 0000000000000..650d26457a064 --- /dev/null +++ b/scripts/format-svg.js @@ -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) diff --git a/www/src/assets/showcase-feather.svg b/www/src/assets/showcase-feather.svg index f8d57129ba8c9..9cedd550e693b 100644 --- a/www/src/assets/showcase-feather.svg +++ b/www/src/assets/showcase-feather.svg @@ -1,19 +1,14 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + +