vite-svg-to-ico 0.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/LICENSE +21 -0
- package/README.md +83 -0
- package/dist/index.d.mts +89 -0
- package/dist/index.mjs +247 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kaj Kowalski
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# vite-svg-to-ico
|
|
2
|
+
|
|
3
|
+
Vite plugin that converts an SVG file into a multi-size `.ico` favicon at build time. Serves the generated ICO during development with HMR support.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install -D vite-svg-to-ico
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Requires [`sharp`](https://sharp.pixelplumbing.com/) as a runtime dependency (installed automatically).
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
// vite.config.ts
|
|
17
|
+
import { defineConfig } from "vite";
|
|
18
|
+
import svgToIco from "vite-svg-to-ico";
|
|
19
|
+
|
|
20
|
+
export default defineConfig({
|
|
21
|
+
plugins: [svgToIco({ input: "src/icon.svg" })],
|
|
22
|
+
});
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Custom sizes and output filename
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
svgToIco({
|
|
29
|
+
input: "src/logo.svg",
|
|
30
|
+
output: "icon.ico",
|
|
31
|
+
sizes: [16, 24, 32, 48, 64, 128, 256],
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Skip PNG optimization for faster builds
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
svgToIco({
|
|
39
|
+
input: "src/icon.svg",
|
|
40
|
+
optimize: false,
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Emit the source SVG alongside the ICO
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
svgToIco({
|
|
48
|
+
input: "src/icon.svg",
|
|
49
|
+
includeSource: true,
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Emit the source SVG with a custom filename
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
svgToIco({
|
|
57
|
+
input: "src/icon.svg",
|
|
58
|
+
includeSource: { name: "logo.svg" },
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Options
|
|
63
|
+
|
|
64
|
+
| Option | Type | Default | Description |
|
|
65
|
+
| --------------- | -------------------------------- | --------------- | --------------------------------------------------- |
|
|
66
|
+
| `input` | `string` | **(required)** | Path to the source SVG file. |
|
|
67
|
+
| `output` | `string` | `'favicon.ico'` | Output filename for the generated ICO. |
|
|
68
|
+
| `sizes` | `number \| number[]` | `[16, 32, 48]` | Pixel dimensions to rasterize (1-256). |
|
|
69
|
+
| `optimize` | `boolean` | `true` | Max PNG compression (level 9 + adaptive filtering). |
|
|
70
|
+
| `includeSource` | `boolean \| { name?, enabled? }` | `false` | Emit the source SVG alongside the ICO. |
|
|
71
|
+
|
|
72
|
+
## How it works
|
|
73
|
+
|
|
74
|
+
- **Build**: reads the SVG, rasterizes it to PNG at each size via `sharp`, packs the PNGs into an ICO container (PNG-in-ICO format), and emits it as a Rollup asset.
|
|
75
|
+
- **Dev**: pre-generates the ICO on server start and serves it via middleware. Regenerates automatically when the source SVG changes (HMR).
|
|
76
|
+
|
|
77
|
+
## Debug
|
|
78
|
+
|
|
79
|
+
Set `DEBUG=vite-svg-to-ico` to enable timing instrumentation.
|
|
80
|
+
|
|
81
|
+
## License
|
|
82
|
+
|
|
83
|
+
[MIT](https://github.com/kjanat/vite-svg-to-ico/blob/master/LICENSE)
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { Plugin } from "vite";
|
|
2
|
+
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
/** Configuration for the [`vite-svg-to-ico`](https://github.com/kjanat/vite-svg-to-ico "GitHub") plugin.
|
|
5
|
+
* @see https://npmjs.com/package/vite-svg-to-ico#options
|
|
6
|
+
*/
|
|
7
|
+
interface PluginOptions {
|
|
8
|
+
/** Absolute or root-relative path to the source SVG file. */
|
|
9
|
+
input: string;
|
|
10
|
+
/** Output filename for the generated `.ico` asset.
|
|
11
|
+
* @default 'favicon.ico' */
|
|
12
|
+
output?: string;
|
|
13
|
+
/** Pixel dimensions to rasterize (each value produces a square PNG layer).
|
|
14
|
+
*
|
|
15
|
+
* A single value is wrapped into an array automatically.
|
|
16
|
+
* Must be integers in the range 1–256 per the ICO spec.
|
|
17
|
+
* @default [16, 32, 48] */
|
|
18
|
+
sizes?: IconSize | IconSize[];
|
|
19
|
+
/** Apply maximum PNG compression (level 9 + adaptive filtering).
|
|
20
|
+
* @default true */
|
|
21
|
+
optimize?: boolean;
|
|
22
|
+
/** Copy over the input SVG file to the output directory alongside the ICO.
|
|
23
|
+
*
|
|
24
|
+
* Pass `true` to emit with the original basename, or an object to customise.
|
|
25
|
+
* @default false */
|
|
26
|
+
includeSource?: boolean | IncludeSourceOptions;
|
|
27
|
+
}
|
|
28
|
+
/** Common ICO pixel dimensions with IDE autocompletion; any integer 1–256 is accepted. */
|
|
29
|
+
type IconSize = 16 | 24 | 32 | 48 | 64 | 128 | 256 | (number & {});
|
|
30
|
+
/** Fine-grained control for emitting the source SVG alongside the ICO. */
|
|
31
|
+
interface IncludeSourceOptions {
|
|
32
|
+
/** Override the output filename for the emitted SVG.
|
|
33
|
+
* @default basename(input) */
|
|
34
|
+
name?: string;
|
|
35
|
+
/** Whether to emit the source SVG.
|
|
36
|
+
* @default true */
|
|
37
|
+
enabled?: boolean;
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/index.d.ts
|
|
41
|
+
/**
|
|
42
|
+
* Vite plugin that converts an SVG source into a multi-size `.ico` favicon.
|
|
43
|
+
*
|
|
44
|
+
* @description
|
|
45
|
+
* Returns three composable sub-plugins:
|
|
46
|
+
* 1. **config** — validates options after config is resolved.
|
|
47
|
+
* 2. **serve** — lazily generates the ICO and serves it via dev-server middleware;
|
|
48
|
+
* regenerates on HMR when the source SVG changes.
|
|
49
|
+
* 3. **build** — generates the ICO at build time and emits it as a Rollup asset.
|
|
50
|
+
*
|
|
51
|
+
* @example Basic usage
|
|
52
|
+
* // vite.config.ts
|
|
53
|
+
* import { defineConfig } from 'vite';
|
|
54
|
+
* import svgToIco from 'vite-svg-to-ico';
|
|
55
|
+
*
|
|
56
|
+
* export default defineConfig({
|
|
57
|
+
* plugins: [
|
|
58
|
+
* svgToIco({ input: 'src/icon.svg' }),
|
|
59
|
+
* ],
|
|
60
|
+
* });
|
|
61
|
+
*
|
|
62
|
+
* @example Custom sizes and output filename
|
|
63
|
+
* svgToIco({
|
|
64
|
+
* input: 'src/logo.svg',
|
|
65
|
+
* output: 'icon.ico',
|
|
66
|
+
* sizes: [16, 24, 32, 48, 64, 128, 256],
|
|
67
|
+
* })
|
|
68
|
+
*
|
|
69
|
+
* @example Skip PNG optimization for faster builds
|
|
70
|
+
* svgToIco({
|
|
71
|
+
* input: 'src/icon.svg',
|
|
72
|
+
* optimize: false,
|
|
73
|
+
* })
|
|
74
|
+
*
|
|
75
|
+
* @example Emit the source SVG alongside the ICO
|
|
76
|
+
* svgToIco({
|
|
77
|
+
* input: 'src/icon.svg',
|
|
78
|
+
* includeSource: true,
|
|
79
|
+
* })
|
|
80
|
+
*
|
|
81
|
+
* @example Emit the source SVG with a custom filename
|
|
82
|
+
* svgToIco({
|
|
83
|
+
* input: 'src/icon.svg',
|
|
84
|
+
* includeSource: { name: 'logo.svg' },
|
|
85
|
+
* })
|
|
86
|
+
*/
|
|
87
|
+
declare function svgToIco(opts: PluginOptions): Plugin[];
|
|
88
|
+
//#endregion
|
|
89
|
+
export { type IconSize, type IncludeSourceOptions, type PluginOptions, svgToIco as default };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { basename } from "node:path";
|
|
3
|
+
import sharp from "sharp";
|
|
4
|
+
|
|
5
|
+
//#region src/ico.ts
|
|
6
|
+
/**
|
|
7
|
+
* Rasterize an SVG to multiple PNG sizes and pack them into an ICO buffer.
|
|
8
|
+
*
|
|
9
|
+
* @param svg - SVG contents as a Buffer, or a filesystem path to read.
|
|
10
|
+
* @param sizes - Square pixel dimensions for each PNG layer.
|
|
11
|
+
* @param optimize - Whether to use maximum PNG compression.
|
|
12
|
+
* @returns ICO file contents as a {@link Buffer}.
|
|
13
|
+
*/
|
|
14
|
+
async function generateIco(svg, sizes, optimize) {
|
|
15
|
+
const svgBuffer = Buffer.isBuffer(svg) ? svg : await readFile(svg);
|
|
16
|
+
return packIco(await Promise.all(sizes.map((size) => sharp(svgBuffer).resize(size, size, {
|
|
17
|
+
fit: "contain",
|
|
18
|
+
background: {
|
|
19
|
+
r: 0,
|
|
20
|
+
g: 0,
|
|
21
|
+
b: 0,
|
|
22
|
+
alpha: 0
|
|
23
|
+
}
|
|
24
|
+
}).png({
|
|
25
|
+
compressionLevel: optimize ? 9 : 6,
|
|
26
|
+
adaptiveFiltering: optimize
|
|
27
|
+
}).toBuffer())), sizes);
|
|
28
|
+
}
|
|
29
|
+
/** ICO type identifier (1 = icon, 2 = cursor). */
|
|
30
|
+
const ICO_TYPE = 1;
|
|
31
|
+
/** Byte length of the ICONDIR header. */
|
|
32
|
+
const HEADER_SIZE = 6;
|
|
33
|
+
/** Byte length of a single ICONDIRENTRY. */
|
|
34
|
+
const ENTRY_SIZE = 16;
|
|
35
|
+
/**
|
|
36
|
+
* Pack pre-rendered PNG buffers into an ICO container.
|
|
37
|
+
*
|
|
38
|
+
* Uses the modern PNG-in-ICO format (supported since Windows Vista).
|
|
39
|
+
* Each PNG is stored verbatim — no BMP conversion or pixel manipulation.
|
|
40
|
+
*
|
|
41
|
+
* @see {@link https://en.wikipedia.org/wiki/ICO_(file_format) "ICO (file format)"}
|
|
42
|
+
*/
|
|
43
|
+
function packIco(pngs, sizes) {
|
|
44
|
+
const count = pngs.length;
|
|
45
|
+
const dataOffset = HEADER_SIZE + count * ENTRY_SIZE;
|
|
46
|
+
const header = Buffer.alloc(HEADER_SIZE);
|
|
47
|
+
header.writeUInt16LE(0, 0);
|
|
48
|
+
header.writeUInt16LE(ICO_TYPE, 2);
|
|
49
|
+
header.writeUInt16LE(count, 4);
|
|
50
|
+
let offset = dataOffset;
|
|
51
|
+
const entries = Buffer.alloc(count * ENTRY_SIZE);
|
|
52
|
+
for (const [i, [png, size]] of pngs.map((p, j) => [p, sizes[j] ?? 0]).entries()) {
|
|
53
|
+
const pos = i * ENTRY_SIZE;
|
|
54
|
+
entries.writeUInt8(size >= 256 ? 0 : size, pos);
|
|
55
|
+
entries.writeUInt8(size >= 256 ? 0 : size, pos + 1);
|
|
56
|
+
entries.writeUInt8(0, pos + 2);
|
|
57
|
+
entries.writeUInt8(0, pos + 3);
|
|
58
|
+
entries.writeUInt16LE(1, pos + 4);
|
|
59
|
+
entries.writeUInt16LE(32, pos + 6);
|
|
60
|
+
entries.writeUInt32LE(png.length, pos + 8);
|
|
61
|
+
entries.writeUInt32LE(offset, pos + 12);
|
|
62
|
+
offset += png.length;
|
|
63
|
+
}
|
|
64
|
+
return Buffer.concat([
|
|
65
|
+
header,
|
|
66
|
+
entries,
|
|
67
|
+
...pngs
|
|
68
|
+
]);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/instrumentation.ts
|
|
73
|
+
const DEBUG = process.env.DEBUG === "vite-svg-to-ico";
|
|
74
|
+
/**
|
|
75
|
+
* Debug-only timing instrumentation.
|
|
76
|
+
*
|
|
77
|
+
* Enable with `DEBUG=vite-svg-to-ico`.
|
|
78
|
+
*/
|
|
79
|
+
var Instrumentation = class {
|
|
80
|
+
times = /* @__PURE__ */ new Map();
|
|
81
|
+
/** Begin a labeled timer; no-op when {@link DEBUG} is `false`. */
|
|
82
|
+
start(label) {
|
|
83
|
+
if (!DEBUG) return;
|
|
84
|
+
this.times.set(label, performance.now());
|
|
85
|
+
console.log(`[svg-to-ico] ${label}...`);
|
|
86
|
+
}
|
|
87
|
+
/** Log elapsed time for a previously started label; no-op when {@link DEBUG} is `false`. */
|
|
88
|
+
end(label) {
|
|
89
|
+
if (!DEBUG) return;
|
|
90
|
+
const start = this.times.get(label);
|
|
91
|
+
if (start) {
|
|
92
|
+
const duration = (performance.now() - start).toFixed(2);
|
|
93
|
+
console.log(`[svg-to-ico] ${label} (${duration}ms)`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/index.ts
|
|
100
|
+
/**
|
|
101
|
+
* Vite plugin that converts an SVG source into a multi-size `.ico` favicon.
|
|
102
|
+
*
|
|
103
|
+
* @description
|
|
104
|
+
* Returns three composable sub-plugins:
|
|
105
|
+
* 1. **config** — validates options after config is resolved.
|
|
106
|
+
* 2. **serve** — lazily generates the ICO and serves it via dev-server middleware;
|
|
107
|
+
* regenerates on HMR when the source SVG changes.
|
|
108
|
+
* 3. **build** — generates the ICO at build time and emits it as a Rollup asset.
|
|
109
|
+
*
|
|
110
|
+
* @example Basic usage
|
|
111
|
+
* // vite.config.ts
|
|
112
|
+
* import { defineConfig } from 'vite';
|
|
113
|
+
* import svgToIco from 'vite-svg-to-ico';
|
|
114
|
+
*
|
|
115
|
+
* export default defineConfig({
|
|
116
|
+
* plugins: [
|
|
117
|
+
* svgToIco({ input: 'src/icon.svg' }),
|
|
118
|
+
* ],
|
|
119
|
+
* });
|
|
120
|
+
*
|
|
121
|
+
* @example Custom sizes and output filename
|
|
122
|
+
* svgToIco({
|
|
123
|
+
* input: 'src/logo.svg',
|
|
124
|
+
* output: 'icon.ico',
|
|
125
|
+
* sizes: [16, 24, 32, 48, 64, 128, 256],
|
|
126
|
+
* })
|
|
127
|
+
*
|
|
128
|
+
* @example Skip PNG optimization for faster builds
|
|
129
|
+
* svgToIco({
|
|
130
|
+
* input: 'src/icon.svg',
|
|
131
|
+
* optimize: false,
|
|
132
|
+
* })
|
|
133
|
+
*
|
|
134
|
+
* @example Emit the source SVG alongside the ICO
|
|
135
|
+
* svgToIco({
|
|
136
|
+
* input: 'src/icon.svg',
|
|
137
|
+
* includeSource: true,
|
|
138
|
+
* })
|
|
139
|
+
*
|
|
140
|
+
* @example Emit the source SVG with a custom filename
|
|
141
|
+
* svgToIco({
|
|
142
|
+
* input: 'src/icon.svg',
|
|
143
|
+
* includeSource: { name: 'logo.svg' },
|
|
144
|
+
* })
|
|
145
|
+
*/
|
|
146
|
+
function svgToIco(opts) {
|
|
147
|
+
let generatedIco = null;
|
|
148
|
+
let logger = null;
|
|
149
|
+
const { input, output = "favicon.ico", sizes: rawSizes = [
|
|
150
|
+
16,
|
|
151
|
+
32,
|
|
152
|
+
48
|
|
153
|
+
], optimize = true, includeSource: rawIncludeSource = false } = opts;
|
|
154
|
+
const sizes = Array.isArray(rawSizes) ? rawSizes : [rawSizes];
|
|
155
|
+
const sourceOpts = typeof rawIncludeSource === "object" ? {
|
|
156
|
+
enabled: rawIncludeSource.enabled ?? true,
|
|
157
|
+
name: rawIncludeSource.name ?? basename(input)
|
|
158
|
+
} : {
|
|
159
|
+
enabled: rawIncludeSource,
|
|
160
|
+
name: basename(input)
|
|
161
|
+
};
|
|
162
|
+
return [
|
|
163
|
+
{
|
|
164
|
+
name: "svg-to-ico:config",
|
|
165
|
+
enforce: "post",
|
|
166
|
+
configResolved(config) {
|
|
167
|
+
logger = config.logger;
|
|
168
|
+
if (!input) throw new Error("[svg-to-ico] `input` option is required");
|
|
169
|
+
const invalid = sizes.filter((s) => !Number.isInteger(s) || s < 1 || s > 256);
|
|
170
|
+
if (invalid.length > 0) throw new Error(`[svg-to-ico] Invalid sizes: ${invalid.join(", ")}. Must be integers 1–256.`);
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
name: "svg-to-ico:serve",
|
|
175
|
+
apply: "serve",
|
|
176
|
+
enforce: "post",
|
|
177
|
+
configureServer(server) {
|
|
178
|
+
server.middlewares.use(`/${output}`, async (_req, res, next) => {
|
|
179
|
+
try {
|
|
180
|
+
if (!generatedIco) generatedIco = await generateIco(input, sizes, optimize);
|
|
181
|
+
res.setHeader("Content-Type", "image/x-icon");
|
|
182
|
+
res.end(generatedIco);
|
|
183
|
+
} catch (e) {
|
|
184
|
+
next(e);
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
if (sourceOpts.enabled) server.middlewares.use(`/${sourceOpts.name}`, async (_req, res, next) => {
|
|
188
|
+
try {
|
|
189
|
+
const svgBuffer = await readFile(input);
|
|
190
|
+
res.setHeader("Content-Type", "image/svg+xml");
|
|
191
|
+
res.end(svgBuffer);
|
|
192
|
+
} catch (e) {
|
|
193
|
+
next(e);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
},
|
|
197
|
+
async buildStart() {
|
|
198
|
+
const I = new Instrumentation();
|
|
199
|
+
I.start("Generate ICO (serve)");
|
|
200
|
+
generatedIco = await generateIco(input, sizes, optimize);
|
|
201
|
+
I.end("Generate ICO (serve)");
|
|
202
|
+
},
|
|
203
|
+
async handleHotUpdate({ file, server }) {
|
|
204
|
+
if (file === input) {
|
|
205
|
+
const I = new Instrumentation();
|
|
206
|
+
I.start("Regenerate ICO (HMR)");
|
|
207
|
+
generatedIco = await generateIco(input, sizes, optimize);
|
|
208
|
+
I.end("Regenerate ICO (HMR)");
|
|
209
|
+
server.hot.send({
|
|
210
|
+
type: "full-reload",
|
|
211
|
+
path: `/${output}`
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
name: "svg-to-ico:build",
|
|
218
|
+
apply: "build",
|
|
219
|
+
enforce: "post",
|
|
220
|
+
async buildStart() {
|
|
221
|
+
const I = new Instrumentation();
|
|
222
|
+
I.start("Generate ICO (build)");
|
|
223
|
+
try {
|
|
224
|
+
const svgBuffer = await readFile(input);
|
|
225
|
+
const icoBuffer = await generateIco(svgBuffer, sizes, optimize);
|
|
226
|
+
this.emitFile({
|
|
227
|
+
type: "asset",
|
|
228
|
+
fileName: output,
|
|
229
|
+
source: icoBuffer
|
|
230
|
+
});
|
|
231
|
+
if (sourceOpts.enabled) this.emitFile({
|
|
232
|
+
type: "asset",
|
|
233
|
+
fileName: sourceOpts.name,
|
|
234
|
+
source: svgBuffer
|
|
235
|
+
});
|
|
236
|
+
I.end("Generate ICO (build)");
|
|
237
|
+
if (DEBUG && logger) logger.info(`Generated ${output}`);
|
|
238
|
+
} catch (error) {
|
|
239
|
+
this.error(`[svg-to-ico] Failed to generate ICO: ${error}`);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
];
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
//#endregion
|
|
247
|
+
export { svgToIco as default };
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vite-svg-to-ico",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A Vite plugin that converts SVG files to ICO format during the build process.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"vite-plugin",
|
|
7
|
+
"vite",
|
|
8
|
+
"svg",
|
|
9
|
+
"ico",
|
|
10
|
+
"favicon",
|
|
11
|
+
"converter"
|
|
12
|
+
],
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/kjanat/vite-svg-to-ico"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"author": "Kaj Kowalski <info@kajkowalski.nl> (https://github.com/kjanat)",
|
|
19
|
+
"type": "module",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": "./src/index.ts",
|
|
22
|
+
"./package.json": "./package.json"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"bd": "tsdown",
|
|
29
|
+
"build": "tsdown",
|
|
30
|
+
"dev": "tsdown --watch",
|
|
31
|
+
"fmt": "dprint fmt",
|
|
32
|
+
"prepack": "bunx prettier --write README.md",
|
|
33
|
+
"prepublish": "bun bd",
|
|
34
|
+
"typecheck": "tsgo --noEmit"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"sharp": "^0.34.5"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/bun": "latest",
|
|
41
|
+
"@typescript/native-preview": "^7.0.0-dev.20260225.1",
|
|
42
|
+
"dprint": "^0.52.0",
|
|
43
|
+
"tsdown": "^0.20.3",
|
|
44
|
+
"typescript": "^5.9.3",
|
|
45
|
+
"unplugin-unused": "^0.5.7"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"vite": "^6.0.0 || ^7.0.0"
|
|
49
|
+
},
|
|
50
|
+
"packageManager": "bun@1.3.9",
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"exports": {
|
|
53
|
+
".": "./dist/index.mjs",
|
|
54
|
+
"./package.json": "./package.json"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|