From c151a1889c75bae34c6284c63ae3f041fbe5777d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torgeir=20Lorange=20=C3=98stby?= Date: Thu, 8 Aug 2024 15:38:57 +0200 Subject: [PATCH] Declare the icons as consts instead of strings, making them all unique. --- bin/build.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/bin/build.js b/bin/build.js index 081012ca..3b44984a 100644 --- a/bin/build.js +++ b/bin/build.js @@ -123,10 +123,16 @@ function buildIcons (groupName) { createZipArchive(staticDest, '**/*.pdf', staticFolder, `${bundleName}-pdf`) // svgToJs + const customOutputs = [ + { + parser: ({ camelCase, svg }) => `export declare const ${camelCase}: '${svg}'`, + }, + ] const icons = svgToJS({ input: staticDest, banner: `@nrk/core-icons ${groupName} v${version}`, - scale: 16 + scale: 16, + customOutputs }) // Generate iife fse.writeFileSync( @@ -139,7 +145,7 @@ function buildIcons (groupName) { // Generate js and mjs with types for icons and logos fse.writeFileSync(path.join(npmPath, `${bundleName}.js`), icons.cjs) fse.writeFileSync(path.join(npmPath, `${bundleName}.mjs`), icons.esm) - fse.writeFileSync(path.join(npmPath, `${bundleName}.d.ts`), icons.dts) + fse.writeFileSync(path.join(npmPath, `${bundleName}.d.ts`), icons.custom_1) // Generate jsx and mjsx with types for icons and logos fse.writeFileSync(path.join(npmJsxFolder, npmPath, `${bundleName}.js`), icons.cjsx) @@ -154,7 +160,8 @@ function buildIcons (groupName) { const largeIcons = svgToJS({ input: staticLargeDest, banner: `@nrk/core-icons ${groupName} v${version}`, - scale: 16 + scale: 16, + customOutputs }) const npmLargePath = path.join(npmPath, 'large') const largeBundleName = `${bundleName}-large` @@ -170,7 +177,7 @@ function buildIcons (groupName) { // Generate js and mjs with types for icons and logos fse.writeFileSync(path.join(npmLargePath, `${largeBundleName}.js`), largeIcons.cjs) fse.writeFileSync(path.join(npmLargePath, `${largeBundleName}.mjs`), largeIcons.esm) - fse.writeFileSync(path.join(npmLargePath, `${largeBundleName}.d.ts`), largeIcons.dts) + fse.writeFileSync(path.join(npmLargePath, `${largeBundleName}.d.ts`), largeIcons.custom_1) // Generate jsx and mjsx with types for icons and logos fse.writeFileSync(path.join(npmJsxFolder, npmLargePath, `${largeBundleName}.js`), largeIcons.cjsx)