mirror of
https://github.com/Warhammer40kGroup/wh40k-icon.git
synced 2025-12-17 16:30:11 +01:00
49 lines
1.3 KiB
JavaScript
49 lines
1.3 KiB
JavaScript
|
|
const fs = require('fs-extra')
|
||
|
|
const path = require('path')
|
||
|
|
const expand = require('glob-expand')
|
||
|
|
const webfont = require('webfont').default
|
||
|
|
|
||
|
|
const files = expand(
|
||
|
|
{
|
||
|
|
cwd: process.cwd()
|
||
|
|
},
|
||
|
|
'src/svgs/**/*.svg'
|
||
|
|
)
|
||
|
|
|
||
|
|
const config = {
|
||
|
|
files,
|
||
|
|
fontName: 'warhammer40k',
|
||
|
|
baseClass: 'wh40k',
|
||
|
|
classPrefix: 'wh40k-',
|
||
|
|
fontHeight: 128,
|
||
|
|
normalize: true,
|
||
|
|
formats: ['svg', 'ttf', 'eot', 'woff', 'woff2'],
|
||
|
|
glyphTransformFn: obj => {
|
||
|
|
return obj
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
webfont({
|
||
|
|
...config,
|
||
|
|
template: path.join('./src/css.hbs')
|
||
|
|
}).then(result => {
|
||
|
|
fs.ensureDir('dist', error => {
|
||
|
|
if (error) {
|
||
|
|
logger.error(error)
|
||
|
|
} else {
|
||
|
|
webfont({
|
||
|
|
...config,
|
||
|
|
template: path.join('./src/scss.hbs')
|
||
|
|
}).then(result => {
|
||
|
|
fs.writeFileSync(`variables.scss`, result.template)
|
||
|
|
})
|
||
|
|
|
||
|
|
fs.writeFileSync(`dist/${result.config.fontName}.css`, result.template)
|
||
|
|
fs.writeFileSync(`dist/${result.config.fontName}.svg`, result.svg)
|
||
|
|
fs.writeFileSync(`dist/${result.config.fontName}.ttf`, new Buffer.from(result.ttf))
|
||
|
|
fs.writeFileSync(`dist/${result.config.fontName}.eot`, new Buffer.from(result.eot))
|
||
|
|
fs.writeFileSync(`dist/${result.config.fontName}.woff`, new Buffer.from(result.woff))
|
||
|
|
fs.writeFileSync(`dist/${result.config.fontName}.woff2`, new Buffer.from(result.woff2))
|
||
|
|
}
|
||
|
|
})
|
||
|
|
})
|