mirror of
https://github.com/Fechin/reference.git
synced 2026-11-20 21:23:11 +03:00
fix: prevent SVG path corruption during build
Wrap SVG icons with htmlclean-protect comments to prevent minification from corrupting path data, ensuring icons display correctly after build.
This commit is contained in:
1 parent
2f7bfa586c
commit
700e894805
1 file changed
+5
-4
@@ -92,12 +92,13 @@ function svgIcon(name) {
|
||||
// Check file exists
|
||||
const svgPath = path.resolve('./', 'source/assets/icon/', `${name}.svg`);
|
||||
if (fs.existsSync(svgPath)) {
|
||||
return fs.readFileSync(svgPath, 'utf8');
|
||||
const svgContent = fs.readFileSync(svgPath, 'utf8');
|
||||
return `<!--[htmlclean-protect]-->${svgContent}<!--[/htmlclean-protect]-->`;
|
||||
} else {
|
||||
return (
|
||||
const defaultSvg =
|
||||
'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" fill="currentColor" height="1em" width="1em">\n' +
|
||||
' <path d="M886.25058594 98.67324219L137.8385 98.67324219c-39.31382813 0-71.47256836 29.21941406-71.47256836 68.59713867l0 687.8025c0 39.37675781 32.15786133 71.60036133 71.47256836 71.60036133l754.3764 0c39.31382813 0 68.51162109-32.22360352 68.51162109-71.60036133L960.72652109 167.2703C960.72558594 127.89256836 925.56529297 98.67324219 886.25058594 98.67324219zM354.49103516 200.47132812c60.54662109 0 109.63617188 49.04727539 109.63617187 109.5516211 0 60.50425781-49.08867187 109.55162109-109.63617187 109.55162109s-109.63617188-49.04727539-109.63617188-109.55162109C244.85477539 249.51772461 293.94353516 200.47132812 354.49103516 200.47132812zM167.03632813 839.84574219c-8.22058594 0-16.50506836-2.83227539-23.23441407-8.62646485-14.99308594-12.86279297-16.73912109-35.45727539-3.87632812-50.47286132l164.34720703-247.7241211c12.20396484-14.26860352 33.32970703-16.65448242 48.42896484-5.47286133l145.00977539 107.69668946 259.82191407-295.15227539c12.30925781-15.44036133 77.58448242-88.16853516 115.79036132-5.68529297 0.04227539-0.12779297 0.08551758 109.06110352 0.12779297 220.54948242 0.04227539 116.28272461 0.06389648 284.78162109 0.06389649 284.78162109C872.72808594 839.54603516 167.37646484 839.84574219 167.03632813 839.84574219z"></path>\n' +
|
||||
'</svg>'
|
||||
);
|
||||
'</svg>';
|
||||
return `<!--[htmlclean-protect]-->${defaultSvg}<!--[/htmlclean-protect]-->`;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user