2022-06-20 15:27:55 +02:00
|
|
|
module.exports = {
|
|
|
|
plugins: [
|
|
|
|
{
|
2022-06-21 10:00:43 +02:00
|
|
|
name: "preset-default",
|
2022-06-20 15:27:55 +02:00
|
|
|
},
|
2023-07-24 20:53:33 +02:00
|
|
|
{
|
|
|
|
name: "prefixIds",
|
|
|
|
params: {
|
|
|
|
delim: "-",
|
|
|
|
prefix: (_, info) => {
|
|
|
|
if (info.path != null && info.path.length > 0) {
|
|
|
|
return getBasename(info.path).split(".")[0];
|
|
|
|
}
|
|
|
|
return "prefix";
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-06-21 10:00:43 +02:00
|
|
|
"convertStyleToAttrs",
|
|
|
|
"removeDimensions",
|
|
|
|
"removeScriptElement",
|
|
|
|
"removeStyleElement",
|
|
|
|
"sortAttrs",
|
2022-06-20 15:27:55 +02:00
|
|
|
],
|
|
|
|
};
|
2023-07-24 20:53:33 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* extract basename from path
|
|
|
|
* @see https://github.com/svg/svgo/blob/main/plugins/prefixIds.js
|
|
|
|
*/
|
|
|
|
const getBasename = (path) => {
|
|
|
|
const matched = path.match(/[/\\]?([^/\\]+)$/);
|
|
|
|
if (matched) return matched[1];
|
|
|
|
return "";
|
|
|
|
};
|