mirror of
https://github.com/tabler/tabler-icons.git
synced 2025-08-19 12:21:39 +02:00
Change the way of exporting icons in Svelte package (#1169)
+ Updated imports in test-svelte project. Co-authored-by: Bartłomiej Gawęda <bgaweda@abis.krakow.pl>
This commit is contained in:
@@ -1,36 +1,6 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
import { buildJsIcons, buildIconsList } from '../../.build/build-icons.mjs'
|
import { buildJsIcons, buildIconsList } from '../../.build/build-icons.mjs'
|
||||||
import { readFileSync, writeFileSync } from 'fs'
|
|
||||||
import { getAllIcons, toPascalCase } from '../../.build/helpers.mjs'
|
|
||||||
|
|
||||||
const updatePackageJson = () => {
|
|
||||||
let packageJson = JSON.parse(readFileSync('package.json', 'utf-8'))
|
|
||||||
|
|
||||||
if (packageJson.exports) {
|
|
||||||
for (const key in packageJson.exports) {
|
|
||||||
if (key.match(/^\.\/[^\.]+\.svelte$/)) {
|
|
||||||
delete packageJson.exports[key]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const allIcons = getAllIcons(false, false)
|
|
||||||
|
|
||||||
Object.entries(allIcons).forEach(([type, icons]) => {
|
|
||||||
icons.forEach((icon, i) => {
|
|
||||||
const iconName = `${icon.name}${type !== 'outline' ? `-${type}` : ''}`,
|
|
||||||
iconNamePascal = `${icon.namePascal}${type !== 'outline' ? toPascalCase(type) : ''}`
|
|
||||||
|
|
||||||
packageJson.exports[`./${iconNamePascal}.svelte`] = {
|
|
||||||
types: `./dist/icons/${iconName}.svelte.d.ts`,
|
|
||||||
svelte: `./dist/icons/${iconName}.svelte`
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
writeFileSync('package.json', JSON.stringify(packageJson, null, 2))
|
|
||||||
}
|
|
||||||
|
|
||||||
const componentTemplate = ({
|
const componentTemplate = ({
|
||||||
type,
|
type,
|
||||||
@@ -71,5 +41,4 @@ buildJsIcons({
|
|||||||
pascalName: false,
|
pascalName: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
updatePackageJson()
|
|
||||||
buildIconsList('icons-svelte')
|
buildIconsList('icons-svelte')
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import IconAd from "@tabler/icons-svelte/IconAd.svelte";
|
import IconAd from "@tabler/icons-svelte/icons/ad";
|
||||||
import IconAdOff from "@tabler/icons-svelte/IconAdOff.svelte";
|
import IconAdOff from "@tabler/icons-svelte/icons/ad-off";
|
||||||
import IconAdFilled from "@tabler/icons-svelte/IconAdFilled.svelte";
|
import { IconAdFilled } from "@tabler/icons-svelte";
|
||||||
let active = false;
|
let active = false;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user