Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declare the icons "as const" instead of strings #303

Merged
merged 5 commits into from
Aug 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions bin/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
Expand All @@ -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`
Expand All @@ -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)
Expand Down
Loading