mirror of
https://github.com/Mibew/simple-icons.git
synced 2025-05-02 09:06:43 +03:00
Reuse svg
getter package template parts (#7457)
* Reuse svg getter package template parts
This commit is contained in:
parent
986589c34c
commit
e0a4e765ad
@ -106,18 +106,24 @@ const build = async () => {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// constants used in templates to reduce package size
|
||||||
|
const constantsString = `const a='<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>',b='</title><path d="',c='"/></svg>';`;
|
||||||
|
|
||||||
// write our generic index.js
|
// write our generic index.js
|
||||||
const rawIndexJs = util.format(
|
const rawIndexJs = util.format(
|
||||||
indexTemplate,
|
indexTemplate,
|
||||||
|
constantsString,
|
||||||
buildIcons.map(iconToKeyValue).join(','),
|
buildIcons.map(iconToKeyValue).join(','),
|
||||||
);
|
);
|
||||||
await writeJs(indexFile, rawIndexJs);
|
await writeJs(indexFile, rawIndexJs);
|
||||||
|
|
||||||
// write our file containing the exports of all icons in CommonJS ...
|
// write our file containing the exports of all icons in CommonJS ...
|
||||||
const rawIconsJs = `module.exports={${iconsBarrelJs.join('')}};`;
|
const rawIconsJs = `${constantsString}module.exports={${iconsBarrelJs.join(
|
||||||
|
'',
|
||||||
|
)}};`;
|
||||||
await writeJs(iconsJsFile, rawIconsJs);
|
await writeJs(iconsJsFile, rawIconsJs);
|
||||||
// and ESM
|
// and ESM
|
||||||
const rawIconsMjs = iconsBarrelMjs.join('');
|
const rawIconsMjs = constantsString + iconsBarrelMjs.join('');
|
||||||
await writeJs(iconsMjsFile, rawIconsMjs);
|
await writeJs(iconsMjsFile, rawIconsMjs);
|
||||||
// and create a type declaration file
|
// and create a type declaration file
|
||||||
const rawIconsDts = `import {SimpleIcon} from ".";type I = SimpleIcon;${iconsBarrelDts.join(
|
const rawIconsDts = `import {SimpleIcon} from ".";type I = SimpleIcon;${iconsBarrelDts.join(
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
title: '%s',
|
title: '%s',
|
||||||
slug: '%s',
|
slug: '%s',
|
||||||
get svg() {
|
get svg() {
|
||||||
return '<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>%s</title><path d="' + this.path + '"/></svg>';
|
return a + '%s' + b + this.path + c;
|
||||||
},
|
},
|
||||||
path: '%s',
|
path: '%s',
|
||||||
source: '%s',
|
source: '%s',
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
console.warn('Deprecation warning: The `simple-icons` entrypoint will be removed in the next major. Please switch to using `import * as icons from "simple-icons/icons"` if you need an object with all the icons.')
|
console.warn('Deprecation warning: The `simple-icons` entrypoint will be removed in the next major. Please switch to using `import * as icons from "simple-icons/icons"` if you need an object with all the icons.')
|
||||||
|
|
||||||
|
%s
|
||||||
|
|
||||||
var icons = {%s};
|
var icons = {%s};
|
||||||
|
|
||||||
Object.defineProperty(icons, "Get", {
|
Object.defineProperty(icons, "Get", {
|
||||||
|
Loading…
Reference in New Issue
Block a user