vite-plugin-svg-spritegen 1.2.5 → 1.2.6

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 CHANGED
@@ -14,9 +14,8 @@ const buildSvgMap = async (inputConfigs) => {
14
14
  inputConfigs.map(async (inputConfig) => {
15
15
  const { pattern, baseDir, getSymbolId } = inputConfig;
16
16
  const matchedPaths = await fastGlob(pattern, { cwd: baseDir });
17
- const matchedPathsSorted = matchedPaths.sort((a, b) => a.localeCompare(b));
18
17
  await Promise.all(
19
- matchedPathsSorted.map(async (matchPath) => {
18
+ matchedPaths.map(async (matchPath) => {
20
19
  const filePath = path.join(baseDir, matchPath);
21
20
  const content = await node_fs.promises.readFile(filePath, "utf8");
22
21
  const resolvedInputConfig = {
@@ -84,7 +83,8 @@ const writeGitignore = async (filePath, spriteName, typesName) => {
84
83
  const writeSprite = (spritePath, svgMap) => {
85
84
  const symbols = [];
86
85
  const definitions = [];
87
- for (const svg of svgMap.values()) {
86
+ const svgSorted = [...svgMap].sort((a, b) => String(a[0]).localeCompare(b[0])).map(([_, svg]) => svg);
87
+ for (const svg of svgSorted) {
88
88
  if (spritePath === svg.filePath) continue;
89
89
  let content2 = svg.content;
90
90
  if (svg.svgo !== false) {
package/dist/index.mjs CHANGED
@@ -12,9 +12,8 @@ const buildSvgMap = async (inputConfigs) => {
12
12
  inputConfigs.map(async (inputConfig) => {
13
13
  const { pattern, baseDir, getSymbolId } = inputConfig;
14
14
  const matchedPaths = await fastGlob(pattern, { cwd: baseDir });
15
- const matchedPathsSorted = matchedPaths.sort((a, b) => a.localeCompare(b));
16
15
  await Promise.all(
17
- matchedPathsSorted.map(async (matchPath) => {
16
+ matchedPaths.map(async (matchPath) => {
18
17
  const filePath = path.join(baseDir, matchPath);
19
18
  const content = await promises.readFile(filePath, "utf8");
20
19
  const resolvedInputConfig = {
@@ -82,7 +81,8 @@ const writeGitignore = async (filePath, spriteName, typesName) => {
82
81
  const writeSprite = (spritePath, svgMap) => {
83
82
  const symbols = [];
84
83
  const definitions = [];
85
- for (const svg of svgMap.values()) {
84
+ const svgSorted = [...svgMap].sort((a, b) => String(a[0]).localeCompare(b[0])).map(([_, svg]) => svg);
85
+ for (const svg of svgSorted) {
86
86
  if (spritePath === svg.filePath) continue;
87
87
  let content2 = svg.content;
88
88
  if (svg.svgo !== false) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-svg-spritegen",
3
- "version": "1.2.5",
3
+ "version": "1.2.6",
4
4
  "description": "Vite plugin that generates an svg spritesheet, optionally removing unused svg files.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -1,2 +0,0 @@
1
- import type { InputConfig, SvgMap } from './types';
2
- export declare const buildSvgMap: (inputConfigs: Required<InputConfig>[]) => Promise<SvgMap>;
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import type { Plugin } from 'vite';
2
- import type { PluginConfig } from './types';
3
- export declare function svgSpritegen(config: PluginConfig): Plugin;
package/dist/types.d.ts DELETED
@@ -1,33 +0,0 @@
1
- import { FilterPattern } from 'vite';
2
- import { Config as SvgoConfig } from 'svgo';
3
- export interface InputConfig {
4
- pattern?: string;
5
- baseDir?: string;
6
- prefix?: string;
7
- getSymbolId?: (config: Omit<ResolvedInputConfig, 'symbolId'>) => string;
8
- removeAttrs?: string[];
9
- svgoPlugins?: SvgoConfig['plugins'];
10
- svgo?: SvgoConfig | false;
11
- }
12
- export interface ResolvedInputConfig extends Required<InputConfig> {
13
- symbolId: string;
14
- matchPath: string;
15
- filePath: string;
16
- content: string;
17
- }
18
- export type SvgMap = Map<string, ResolvedInputConfig>;
19
- export interface StripUnusedConfig {
20
- enabled?: boolean;
21
- srcInclude?: FilterPattern;
22
- srcExclude?: FilterPattern;
23
- whitelist?: string[];
24
- }
25
- export interface PluginConfig {
26
- outputDir: string;
27
- input?: InputConfig | InputConfig[];
28
- stripUnused?: boolean | StripUnusedConfig;
29
- typesFileName?: string;
30
- spriteFileName?: string;
31
- gitignore?: boolean;
32
- matchPattern?: string | RegExp;
33
- }
@@ -1 +0,0 @@
1
- export declare const writeGitignore: (filePath: string, spriteName: string, typesName: string) => Promise<void>;
@@ -1 +0,0 @@
1
- export declare const writeIfChanged: (filePath: string, content?: string) => boolean;
@@ -1,2 +0,0 @@
1
- import type { SvgMap } from './types';
2
- export declare const writeSprite: (spritePath: string, svgMap: SvgMap) => string;
@@ -1,2 +0,0 @@
1
- import { SvgMap } from './types';
2
- export declare const writeTypes: (filePath: string, svgMap: SvgMap) => Promise<void>;