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:
@@ -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>/
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user