Skip to content

Commit

Permalink
chore(icons): add svgo
Browse files Browse the repository at this point in the history
  • Loading branch information
felipefialho committed Nov 19, 2024
1 parent 67ebf03 commit 0a4628b
Show file tree
Hide file tree
Showing 3 changed files with 171 additions and 58 deletions.
209 changes: 165 additions & 44 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^8.12.2",
"@typescript-eslint/parser": "^8.12.2",
"@vitejs/plugin-vue": "^5.1.3",
"autoprefixer": "^10.4.20",
"babel-loader": "^9.1.3",
"babel-plugin-transform-scss": "^1.2.0",
Expand Down Expand Up @@ -99,12 +100,12 @@
"stylelint-config-recommended": "^14.0.1",
"stylelint-order": "^6.0.4",
"stylelint-scss": "^6.5.1",
"svgo": "^3.3.2",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",
"tslib": "^2.8.1",
"typescript": "^5.5.4",
"vite": "^5.4.2",
"@vitejs/plugin-vue": "^5.1.3",
"vue": "^3.4.38"
},
"lint-staged": {
Expand Down
17 changes: 4 additions & 13 deletions packages/icons/scripts/build.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
import path from 'path'

import { optimize } from 'svgo'

import { readSvg, readSvgDirectories, writeSvgFile } from './helpers.js'

function optimizeSvg(path: string, svg: string) {
const config = [
{
name: 'preset-default',
params: {
overrides: {
convertShapeToPath: false,
mergePaths: false,
removeViewBox: false,
},
},
},
]
const optimizedSvg = optimize(svg, { path, plugins: config })
const optimizedSvg = optimize(svg, { path })

return optimizedSvg.data
}

Expand All @@ -28,6 +18,7 @@ function build() {
const basename = path.basename(file)
const content = readSvg(file)
const optimizedFile = optimizeSvg(file, content)

writeSvgFile(basename, optimizedFile)
}
}
Expand Down

0 comments on commit 0a4628b

Please sign in to comment.