mirror of
https://github.com/tabler/tabler-icons.git
synced 2025-09-03 02:42:55 +02:00
Build webfont fix (#1043)
This commit is contained in:
@@ -107,6 +107,25 @@ const buildOutline = async () => {
|
||||
})
|
||||
})
|
||||
|
||||
// Copy icons from firs to all directory
|
||||
await asyncForEach(Object.entries(icons), async ([type, icons]) => {
|
||||
fs.mkdirSync(resolve(DIR, `icons-outlined/all`), { recursive: true })
|
||||
|
||||
await asyncForEach(icons, async function ({ name, unicode }) {
|
||||
const iconName = `u${unicode.toUpperCase()}-${name}`
|
||||
|
||||
if (fs.existsSync(resolve(DIR, `icons-outlined/${type}/${iconName}.svg`))) {
|
||||
// Copy file
|
||||
console.log(`Copy ${iconName} to all directory`)
|
||||
|
||||
fs.copyFileSync(
|
||||
resolve(DIR, `icons-outlined/${type}/${iconName}.svg`),
|
||||
resolve(DIR, `icons-outlined/all/${iconName}${type !== 'outline' ? `-${type}` : ''}.svg`)
|
||||
)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
console.log('Done')
|
||||
}
|
||||
|
||||
|
@@ -12,6 +12,20 @@ const aliases = getAliases(true)
|
||||
|
||||
fs.mkdirSync(`${DIR}/dist/fonts`, { recursive: true })
|
||||
|
||||
types.push('all')
|
||||
|
||||
const getAlliasesFlat = () => {
|
||||
let allAliases = {}
|
||||
|
||||
Object.entries(aliases).forEach(([type, aliases]) => {
|
||||
Object.entries(aliases).forEach(([from, to]) => {
|
||||
allAliases[`${from}${type !== 'outline' ? `-${type}` : ''}`] = `${to}${type !== 'outline' ? `-${type}` : ''}`
|
||||
})
|
||||
})
|
||||
|
||||
return allAliases
|
||||
}
|
||||
|
||||
asyncForEach(types, async type => {
|
||||
console.log(`Building webfont for ${type} icons`)
|
||||
|
||||
@@ -28,7 +42,7 @@ asyncForEach(types, async type => {
|
||||
})
|
||||
.then((result) => {
|
||||
formats.forEach(format => {
|
||||
fs.writeFileSync(`${DIR}/dist/fonts/tabler-icons${type !== 'outline' ? `-${type}` : ''}.${format}`, result[format])
|
||||
fs.writeFileSync(`${DIR}/dist/fonts/tabler-icons${type !== 'all' ? `-${type}` : ''}.${format}`, result[format])
|
||||
})
|
||||
|
||||
const glyphs = result.glyphsData
|
||||
@@ -37,24 +51,23 @@ asyncForEach(types, async type => {
|
||||
return ('' + a.name).localeCompare(b.name)
|
||||
})
|
||||
|
||||
console.log(aliases[type])
|
||||
const options = {
|
||||
name: `Tabler Icons${type !== 'outline' ? ` ${toPascalCase(type)}` : ''}`,
|
||||
fileName: `tabler-icons${type !== 'outline' ? `-${type}` : ''}`,
|
||||
name: `Tabler Icons${type !== 'all' ? ` ${toPascalCase(type)}` : ''}`,
|
||||
fileName: `tabler-icons${type !== 'all' ? `-${type}` : ''}`,
|
||||
glyphs,
|
||||
v: p.version,
|
||||
aliases: aliases[type] || {}
|
||||
aliases: (type === 'all' ? getAlliasesFlat() : aliases[type]) || {}
|
||||
}
|
||||
|
||||
//scss
|
||||
const compiled = template(fs.readFileSync(`${DIR}/.build/iconfont.scss`).toString())
|
||||
const resultSCSS = compiled(options)
|
||||
fs.writeFileSync(`${DIR}/dist/tabler-icons${type !== 'outline' ? `-${type}` : ''}.scss`, resultSCSS)
|
||||
fs.writeFileSync(`${DIR}/dist/tabler-icons${type !== 'all' ? `-${type}` : ''}.scss`, resultSCSS)
|
||||
|
||||
//html
|
||||
const compiledHtml = template(fs.readFileSync(`${DIR}/.build/iconfont.html`).toString())
|
||||
const resultHtml = compiledHtml(options)
|
||||
fs.writeFileSync(`${DIR}/dist/tabler-icons${type !== 'outline' ? `-${type}` : ''}.html`, resultHtml)
|
||||
fs.writeFileSync(`${DIR}/dist/tabler-icons${type !== 'all' ? `-${type}` : ''}.html`, resultHtml)
|
||||
})
|
||||
.catch((error) => {
|
||||
throw error;
|
||||
|
@@ -20,9 +20,10 @@
|
||||
"build:prepare": "mkdir -p icons-outlined dist && rm -fdr dist/*",
|
||||
"build:outline": "node .build/build-outline.mjs",
|
||||
"build:webfont": "rm -fd dist/fonts/* && node .build/build-webfont.mjs",
|
||||
"build:css": "pnpm run build:css:outline && pnpm run build:css:filled",
|
||||
"build:css:outline": "sass dist/tabler-icons.scss dist/tabler-icons.css --style expanded && sass dist/tabler-icons.scss dist/tabler-icons.min.css --style compressed",
|
||||
"build:css": "pnpm run build:css:outline && pnpm run build:css:filled && pnpm run build:css:all",
|
||||
"build:css:filled": "sass dist/tabler-icons-filled.scss dist/tabler-icons-filled.css --style expanded && sass dist/tabler-icons-filled.scss dist/tabler-icons-filled.min.css --style compressed",
|
||||
"build:css:outline": "sass dist/tabler-icons-outline.scss dist/tabler-icons-outline.css --style expanded && sass dist/tabler-icons-outline.scss dist/tabler-icons-outline.min.css --style compressed",
|
||||
"build:css:all": "sass dist/tabler-icons.scss dist/tabler-icons.css --style expanded && sass dist/tabler-icons.scss dist/tabler-icons.min.css --style compressed",
|
||||
"clean": "rm -rf dist && rm -rf ./icons-outlined",
|
||||
"copy": "pnpm run copy:license",
|
||||
"copy:license": "cp ../../LICENSE ./LICENSE"
|
||||
|
Reference in New Issue
Block a user