vite-plugin-svg-spritegen 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +6 -8
- package/dist/index.mjs +6 -8
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -74,7 +74,7 @@ const writeSprite = async (spritePath, svgMap) => {
|
|
|
74
74
|
const definitions = [];
|
|
75
75
|
await Promise.all(
|
|
76
76
|
[...svgMap.values()].map(async (inputConfig) => {
|
|
77
|
-
const { svgo: svgo$1, removeAttrs, symbolId, filePath } = inputConfig;
|
|
77
|
+
const { svgo: svgo$1, svgoPlugins = [], removeAttrs, symbolId, filePath } = inputConfig;
|
|
78
78
|
if (spritePath === filePath) return;
|
|
79
79
|
let svgContent = await node_fs.promises.readFile(filePath, "utf8");
|
|
80
80
|
if (svgo$1 !== false) {
|
|
@@ -89,7 +89,8 @@ const writeSprite = async (spritePath, svgMap) => {
|
|
|
89
89
|
attrs: `(${removeAttrs.join("|")})`
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
] : []
|
|
92
|
+
] : [],
|
|
93
|
+
...svgoPlugins
|
|
93
94
|
]
|
|
94
95
|
}).data;
|
|
95
96
|
}
|
|
@@ -133,18 +134,15 @@ const svgoDefault = {
|
|
|
133
134
|
}
|
|
134
135
|
}
|
|
135
136
|
},
|
|
136
|
-
"removeDimensions"
|
|
137
|
-
{
|
|
138
|
-
name: "removeAttrs",
|
|
139
|
-
params: { attrs: "(stroke-width|stroke-linecap|stroke-linejoin|class)" }
|
|
140
|
-
}
|
|
137
|
+
"removeDimensions"
|
|
141
138
|
]
|
|
142
139
|
};
|
|
143
140
|
const inputConfigDefaults = {
|
|
144
141
|
pattern: "**/*.svg",
|
|
145
142
|
baseDir: "./",
|
|
146
143
|
prefix: "",
|
|
147
|
-
removeAttrs: [],
|
|
144
|
+
removeAttrs: ["stroke-width", "stroke-linecap", "stroke-linejoin", "class"],
|
|
145
|
+
svgoPlugins: [],
|
|
148
146
|
svgo: svgoDefault,
|
|
149
147
|
getSymbolId: (config) => config.prefix + config.matchPath.replace(/\.[^/.]+$/, "").replaceAll("/", "-").toLowerCase()
|
|
150
148
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -72,7 +72,7 @@ const writeSprite = async (spritePath, svgMap) => {
|
|
|
72
72
|
const definitions = [];
|
|
73
73
|
await Promise.all(
|
|
74
74
|
[...svgMap.values()].map(async (inputConfig) => {
|
|
75
|
-
const { svgo, removeAttrs, symbolId, filePath } = inputConfig;
|
|
75
|
+
const { svgo, svgoPlugins = [], removeAttrs, symbolId, filePath } = inputConfig;
|
|
76
76
|
if (spritePath === filePath) return;
|
|
77
77
|
let svgContent = await promises.readFile(filePath, "utf8");
|
|
78
78
|
if (svgo !== false) {
|
|
@@ -87,7 +87,8 @@ const writeSprite = async (spritePath, svgMap) => {
|
|
|
87
87
|
attrs: `(${removeAttrs.join("|")})`
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
-
] : []
|
|
90
|
+
] : [],
|
|
91
|
+
...svgoPlugins
|
|
91
92
|
]
|
|
92
93
|
}).data;
|
|
93
94
|
}
|
|
@@ -131,18 +132,15 @@ const svgoDefault = {
|
|
|
131
132
|
}
|
|
132
133
|
}
|
|
133
134
|
},
|
|
134
|
-
"removeDimensions"
|
|
135
|
-
{
|
|
136
|
-
name: "removeAttrs",
|
|
137
|
-
params: { attrs: "(stroke-width|stroke-linecap|stroke-linejoin|class)" }
|
|
138
|
-
}
|
|
135
|
+
"removeDimensions"
|
|
139
136
|
]
|
|
140
137
|
};
|
|
141
138
|
const inputConfigDefaults = {
|
|
142
139
|
pattern: "**/*.svg",
|
|
143
140
|
baseDir: "./",
|
|
144
141
|
prefix: "",
|
|
145
|
-
removeAttrs: [],
|
|
142
|
+
removeAttrs: ["stroke-width", "stroke-linecap", "stroke-linejoin", "class"],
|
|
143
|
+
svgoPlugins: [],
|
|
146
144
|
svgo: svgoDefault,
|
|
147
145
|
getSymbolId: (config) => config.prefix + config.matchPath.replace(/\.[^/.]+$/, "").replaceAll("/", "-").toLowerCase()
|
|
148
146
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export interface InputConfig {
|
|
|
6
6
|
prefix?: string;
|
|
7
7
|
getSymbolId?: (config: Omit<ResolvedInputConfig, 'symbolId'>) => string;
|
|
8
8
|
removeAttrs?: string[];
|
|
9
|
+
svgoPlugins?: SvgoConfig['plugins'];
|
|
9
10
|
svgo?: SvgoConfig | false;
|
|
10
11
|
}
|
|
11
12
|
export interface ResolvedInputConfig extends Required<InputConfig> {
|
package/package.json
CHANGED