Skip to content

Commit

Permalink
SVGO build
Browse files Browse the repository at this point in the history
  • Loading branch information
jerryjappinen committed Jul 15, 2024
1 parent 1aacbb1 commit 06ead01
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
20 changes: 12 additions & 8 deletions build/optimizeIcons.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// https://github.com/svg/svgo?tab=readme-ov-file#api-usage
const {
// loadConfig,
loadConfig,
optimize
} = require('svgo')

Expand All @@ -10,14 +10,18 @@ const getFileList = require('./utils/getFileList')
const readFile = require('./utils/readFile')
const writeTextFile = require('./utils/writeTextFile')

// const config = await loadConfig()

const sourceDir = path.resolve(__dirname, '../icons/') + '/'
const filePaths = getFileList(sourceDir, 'svg')

filePaths.forEach((filePath) => {
const svgString = readFile(filePath)
const optimized = optimize(svgString)
async function build () {
const config = await loadConfig()

filePaths.forEach((filePath) => {
const svgString = readFile(filePath)
const optimized = optimize(svgString, config)

writeTextFile(filePath, optimized.data)
})
}

writeTextFile(filePath, optimized.data)
})
build()
2 changes: 1 addition & 1 deletion svgo.config.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// https://github.com/svg/svgo
export default {
multipass: false, // boolean
datauri: 'base64', // 'base64'|'enc'|'unenc'
// datauri: 'base64', // 'base64'|'enc'|'unenc'
js2svg: {
indent: 4, // number
pretty: false // boolean
Expand Down

0 comments on commit 06ead01

Please sign in to comment.