commit cedcf86d4b4d58a02461d6558ec18bdd50b72aef Author: molingyu Date: Fri Sep 28 23:44:58 2018 +0800 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7de7d68 --- /dev/null +++ b/.gitignore @@ -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/ \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..f6a34da --- /dev/null +++ b/package.json @@ -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" + } +} diff --git a/scripts/font-build.js b/scripts/font-build.js new file mode 100644 index 0000000..83210f9 --- /dev/null +++ b/scripts/font-build.js @@ -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)) + } + }) +}) \ No newline at end of file