Merged in feat/sw-3713-svg-optimize (pull request #3516)

feat(SW-3713): Optimize all SVGs

* feat(SW-3713): Optimize all SVGs


Approved-by: Anton Gunnarsson
This commit is contained in:
Linus Flood
2026-01-30 07:00:09 +00:00
parent 4d298b0b9b
commit 28974b979d
607 changed files with 726 additions and 7638 deletions

View File

@@ -8,6 +8,7 @@ import {
} from "node:fs/promises"
import { resolve, join } from "node:path"
import { existsSync } from "node:fs"
import { optimize } from "svgo"
// Your full list of Material Symbol icon names
const ICONS = [
@@ -284,7 +285,14 @@ async function main() {
for (const variant of variants) {
if (existsSync(variant.path)) {
const content = await readFile(variant.path, "utf8")
const rawContent = await readFile(variant.path, "utf8")
// Optimize SVG with SVGO
const optimized = optimize(rawContent, {
multipass: true,
})
const content = optimized.data
const svgMatch = content.match(
/<svg[^>]*viewBox="([^"]*)"[^>]*>([\s\S]*?)<\/svg>/
)