mirror of
https://github.com/ionic-team/ionicons.git
synced 2026-11-30 16:48:16 +01:00
chore: sync with main
This commit is contained in:
+12
-8
@@ -53,6 +53,16 @@ async function optimizeSvgs(srcSvgData: SvgData[]) {
|
||||
if (!Array.isArray(params.attrs)) {
|
||||
params.attrs = [params.attrs];
|
||||
}
|
||||
|
||||
/**
|
||||
* All host SVG elements must have
|
||||
* the ionicons class otherwise styles
|
||||
* will not apply.
|
||||
*/
|
||||
if (item.elem === 'svg') {
|
||||
item.class.add('ionicon');
|
||||
}
|
||||
|
||||
if (item.isElem()) {
|
||||
item.eachAttr((attr) => {
|
||||
if (attr.name === 'fill') {
|
||||
@@ -167,14 +177,8 @@ async function optimizeSvg(
|
||||
const srcSvgContent = await fs.readFile(svgData.srcFilePath, 'utf8');
|
||||
|
||||
const optimizedSvg = await optimizePass.optimize(srcSvgContent, { path: svgData.srcFilePath });
|
||||
|
||||
const optimizedCode = optimizedSvg.data.replace(
|
||||
/<svg (.*?)>/,
|
||||
`<svg xmlns="http://www.w3.org/2000/svg" class="ionicon" viewBox="0 0 512 512">`,
|
||||
);
|
||||
|
||||
const webComponentSvg = await webComponentPass.optimize(optimizedCode, { path: svgData.srcFilePath });
|
||||
const sourceSvg = await sourcePass.optimize(optimizedCode, { path: svgData.srcFilePath });
|
||||
const webComponentSvg = await webComponentPass.optimize(optimizedSvg.data, { path: svgData.srcFilePath });
|
||||
const sourceSvg = await sourcePass.optimize(optimizedSvg.data, { path: svgData.srcFilePath });
|
||||
|
||||
svgData.optimizedSvgContent = webComponentSvg.data;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user