Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Commit

Permalink
Build: Replace Squoosh with Sharp
Browse files Browse the repository at this point in the history
  • Loading branch information
danisztls committed Aug 9, 2022
1 parent 8847a5a commit 34be48e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
"scripts": {
"start": "grunt watch",
"minify:svg": "svgo --config=.svgo.config.js --quiet --recursive --folder ./ --exclude principles-paper-ink.svg",
"build:squoosh": "squoosh-cli --oxipng '{\"level\": 4}' -d img/components/ img/components/*.png && squoosh-cli --oxipng '{\"level\": 4}' -d img/design-principles/ img/design-principles/*.png && squoosh-cli --oxipng '{\"level\": 4}' -d img/visual-style/ img/visual-style/*.png && squoosh-cli --oxipng '{\"level\": 4}' -d resources/ resources/!\\(WikimediaUI-components_overview\\).png",
"build": "npm run minify:svg && grunt && npx npm-run-all build:*",
"build:png": "npm run svg-to-png.mjs",
"build": "npm run minify:svg && grunt & npm run build:png",
"test": "grunt lint"
}
}
22 changes: 22 additions & 0 deletions svg-to-png.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import glob from 'glob';
import sharp from 'sharp';

glob( '{img/{components,design-principles,visual-style},resources}/**/!(WikimediaUI-components_overview).svg', ( er, files ) => {
files.forEach( ( file ) => {
sharp( file )
.png( {
// force color indexing
quality: 99,
timeout: 180
} )
.toFile( file.replace( '.svg', '.png' ) )
// eslint-disable-next-line
.then( ( info ) => {
console.log( file );
// console.log( info );
} )
.catch( ( err ) => {
console.log( err );
} );
} );
} );

0 comments on commit 34be48e

Please sign in to comment.