first commit

This commit is contained in:
molingyu 2018-09-28 23:44:58 +08:00
commit cedcf86d4b
3 changed files with 153 additions and 0 deletions

85
.gitignore vendored Normal file
View file

@ -0,0 +1,85 @@
#Build generated
dist/
tools/cli/build
### Parcel ###
.cache/
### Node ###
package-lock.json
yarn-lock.json
yarn.lock
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Coverage directory used by tools like istanbul
coverage
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules
jspm_packages
bower_components
# Yarn Integrity file
.yarn-integrity
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# dotenv environment variables file
.env
### Sass ###
.sass-cache/
*.css.map
### SublimeText ###
# cache files for sublime text
*.tmlanguage.cache
*.tmPreferences.cache
*.stTheme.cache
# workspace files are user-specific
*.sublime-workspace
# project files should be checked into the repository, unless a significant
# proportion of contributors will probably not be using SublimeText
# *.sublime-project
### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
### System Files ###
.DS_Store
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/

19
package.json Normal file
View file

@ -0,0 +1,19 @@
{
"name": "wh40k-icon",
"version": "0.1.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "node ./scripts/font-build.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"warhammer40k"
],
"author": "shitake",
"license": "MIT",
"devDependencies": {
"glob-expand": "^0.2.1",
"webfont": "^8.1.4"
}
}

49
scripts/font-build.js Normal file
View file

@ -0,0 +1,49 @@
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))
}
})
})