mirror of
https://github.com/SamEyeBam/animate.git
synced 2025-12-18 11:24:40 +00:00
larry babby and threejs for glsl
This commit is contained in:
30
webGl/my-threejs-test/node_modules/htmlnano/lib/modules/minifySvg.mjs
generated
vendored
Normal file
30
webGl/my-threejs-test/node_modules/htmlnano/lib/modules/minifySvg.mjs
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
import { optionalImport } from '../helpers.mjs';
|
||||
|
||||
/** Minify SVG with SVGO */
|
||||
export default async function minifySvg(tree, options, svgoOptions = {}) {
|
||||
const svgo = await optionalImport('svgo');
|
||||
|
||||
if (!svgo) return tree;
|
||||
|
||||
tree.match({tag: 'svg'}, node => {
|
||||
let svgStr = tree.render(node, { closingSingleTag: 'slash', quoteAllAttributes: true });
|
||||
try {
|
||||
const result = svgo.optimize(svgStr, svgoOptions);
|
||||
node.tag = false;
|
||||
node.attrs = {};
|
||||
// result.data is a string, we need to cast it to an array
|
||||
node.content = [result.data];
|
||||
return node;
|
||||
} catch (error) {
|
||||
console.error('htmlnano fails to minify the svg:');
|
||||
console.error(error);
|
||||
if (error.name === 'SvgoParserError') {
|
||||
console.error(error.toString());
|
||||
}
|
||||
// We return the node as-is
|
||||
return node;
|
||||
}
|
||||
});
|
||||
|
||||
return tree;
|
||||
}
|
||||
Reference in New Issue
Block a user