vite-plugin-svg-spritegen 1.3.0 → 1.4.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/build-svg-map.d.ts +2 -2
- package/dist/index.js +20 -19
- package/dist/index.mjs +20 -19
- package/dist/types.d.ts +4 -1
- package/package.json +1 -1
package/dist/build-svg-map.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const buildSvgMap: (inputConfigs:
|
|
1
|
+
import type { InputConfigWithDefaults, SvgMap } from './types';
|
|
2
|
+
export declare const buildSvgMap: (inputConfigs: InputConfigWithDefaults[]) => Promise<SvgMap>;
|
package/dist/index.js
CHANGED
|
@@ -88,6 +88,26 @@ const writeSprite = (spritePath, svgMap) => {
|
|
|
88
88
|
if (spritePath === svg.filePath) continue;
|
|
89
89
|
let content2 = svg.content;
|
|
90
90
|
if (svg.svgo !== false) {
|
|
91
|
+
const svgoDefault = {
|
|
92
|
+
plugins: [
|
|
93
|
+
{
|
|
94
|
+
name: "preset-default",
|
|
95
|
+
params: {
|
|
96
|
+
overrides: {
|
|
97
|
+
removeViewBox: false,
|
|
98
|
+
convertColors: { currentColor: true },
|
|
99
|
+
...svg.svgoOverrides
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
"removeDimensions",
|
|
104
|
+
{
|
|
105
|
+
name: "removeAttrs",
|
|
106
|
+
params: { attrs: "(stroke-width|stroke-linecap|stroke-linejoin|class)" }
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
};
|
|
110
|
+
svg.svgo = svg.svgo ?? svgoDefault;
|
|
91
111
|
content2 = svgo.optimize(content2, {
|
|
92
112
|
...svg.svgo,
|
|
93
113
|
plugins: [
|
|
@@ -132,31 +152,12 @@ const writeSprite = (spritePath, svgMap) => {
|
|
|
132
152
|
writeIfChanged(spritePath, content);
|
|
133
153
|
return content;
|
|
134
154
|
};
|
|
135
|
-
const svgoDefault = {
|
|
136
|
-
plugins: [
|
|
137
|
-
{
|
|
138
|
-
name: "preset-default",
|
|
139
|
-
params: {
|
|
140
|
-
overrides: {
|
|
141
|
-
removeViewBox: false,
|
|
142
|
-
convertColors: { currentColor: true }
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
"removeDimensions",
|
|
147
|
-
{
|
|
148
|
-
name: "removeAttrs",
|
|
149
|
-
params: { attrs: "(stroke-width|stroke-linecap|stroke-linejoin|class)" }
|
|
150
|
-
}
|
|
151
|
-
]
|
|
152
|
-
};
|
|
153
155
|
const defaultMatchPattern = /((name)|(iconName)|(icon)):\s?"(?<icon>.+?)"/g;
|
|
154
156
|
const inputConfigDefaults = {
|
|
155
157
|
pattern: "**/*.svg",
|
|
156
158
|
baseDir: "./",
|
|
157
159
|
prefix: "",
|
|
158
160
|
removeAttrs: [],
|
|
159
|
-
svgo: svgoDefault,
|
|
160
161
|
svgoPlugins: [],
|
|
161
162
|
getSymbolId: (config) => config.prefix + config.matchPath.replace(/\.[^/.]+$/, "").replaceAll("/", "-").toLowerCase()
|
|
162
163
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -86,6 +86,26 @@ const writeSprite = (spritePath, svgMap) => {
|
|
|
86
86
|
if (spritePath === svg.filePath) continue;
|
|
87
87
|
let content2 = svg.content;
|
|
88
88
|
if (svg.svgo !== false) {
|
|
89
|
+
const svgoDefault = {
|
|
90
|
+
plugins: [
|
|
91
|
+
{
|
|
92
|
+
name: "preset-default",
|
|
93
|
+
params: {
|
|
94
|
+
overrides: {
|
|
95
|
+
removeViewBox: false,
|
|
96
|
+
convertColors: { currentColor: true },
|
|
97
|
+
...svg.svgoOverrides
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
"removeDimensions",
|
|
102
|
+
{
|
|
103
|
+
name: "removeAttrs",
|
|
104
|
+
params: { attrs: "(stroke-width|stroke-linecap|stroke-linejoin|class)" }
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
};
|
|
108
|
+
svg.svgo = svg.svgo ?? svgoDefault;
|
|
89
109
|
content2 = optimize(content2, {
|
|
90
110
|
...svg.svgo,
|
|
91
111
|
plugins: [
|
|
@@ -130,31 +150,12 @@ const writeSprite = (spritePath, svgMap) => {
|
|
|
130
150
|
writeIfChanged(spritePath, content);
|
|
131
151
|
return content;
|
|
132
152
|
};
|
|
133
|
-
const svgoDefault = {
|
|
134
|
-
plugins: [
|
|
135
|
-
{
|
|
136
|
-
name: "preset-default",
|
|
137
|
-
params: {
|
|
138
|
-
overrides: {
|
|
139
|
-
removeViewBox: false,
|
|
140
|
-
convertColors: { currentColor: true }
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
"removeDimensions",
|
|
145
|
-
{
|
|
146
|
-
name: "removeAttrs",
|
|
147
|
-
params: { attrs: "(stroke-width|stroke-linecap|stroke-linejoin|class)" }
|
|
148
|
-
}
|
|
149
|
-
]
|
|
150
|
-
};
|
|
151
153
|
const defaultMatchPattern = /((name)|(iconName)|(icon)):\s?"(?<icon>.+?)"/g;
|
|
152
154
|
const inputConfigDefaults = {
|
|
153
155
|
pattern: "**/*.svg",
|
|
154
156
|
baseDir: "./",
|
|
155
157
|
prefix: "",
|
|
156
158
|
removeAttrs: [],
|
|
157
|
-
svgo: svgoDefault,
|
|
158
159
|
svgoPlugins: [],
|
|
159
160
|
getSymbolId: (config) => config.prefix + config.matchPath.replace(/\.[^/.]+$/, "").replaceAll("/", "-").toLowerCase()
|
|
160
161
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FilterPattern } from 'vite';
|
|
2
2
|
import { Config as SvgoConfig } from 'svgo';
|
|
3
|
+
import { PresetDefaultOverrides } from 'svgo/plugins/plugins-types';
|
|
3
4
|
export interface InputConfig {
|
|
4
5
|
pattern?: string;
|
|
5
6
|
baseDir?: string;
|
|
@@ -7,9 +8,11 @@ export interface InputConfig {
|
|
|
7
8
|
getSymbolId?: (config: Omit<ResolvedInputConfig, 'symbolId'>) => string;
|
|
8
9
|
removeAttrs?: string[];
|
|
9
10
|
svgoPlugins?: SvgoConfig['plugins'];
|
|
11
|
+
svgoOverrides?: PresetDefaultOverrides;
|
|
10
12
|
svgo?: SvgoConfig | false;
|
|
11
13
|
}
|
|
12
|
-
export
|
|
14
|
+
export type InputConfigWithDefaults = Required<Omit<InputConfig, 'svgoOverrides' | 'svgo'>> & Pick<InputConfig, 'svgoOverrides' | 'svgo'>;
|
|
15
|
+
export interface ResolvedInputConfig extends InputConfigWithDefaults {
|
|
13
16
|
symbolId: string;
|
|
14
17
|
matchPath: string;
|
|
15
18
|
filePath: string;
|
package/package.json
CHANGED