$ cnpm install awesomify-svgs
Convert a directory with SVGs to a Font Awesome 5 supported js data object format. Warning, this package is currently experimental. Use it at your own risk!
For minimal hassle use cases.
awesomify-svgs --help
Usage: cli [options] <source directory> [target directory]
Converts SVGs in a directory to Font Awesome 5 supported js data object format.
Examples:
Convert SVGs from /example-icons to /dist without any grouping:
> awesomify-svgs example-icons
Some designers prefer to create the same icon multiple times with different detail levels.
Eg. user-16.svg is ideal for 16px size while user-32 has more details. Setting --has-variant with
the appropriate separator reults in [icon]-all.js files to be generated with imports to all variant:
> awesomify-svgs --has-variant example-icons
Sometimes certain SVG variants might be missing. Awesomify can be set to generate fallbacks with the
--ensured-variants option. Eg. To make sure [icon]-16, [icon]-32 and [icon]-48 are always ready to import:
> awesomify-svgs --has-variant --ensured-variants "16, 32, 48" example-icons
Options:
-V, --version output the version number
-D, --no-deep ignore sub-directories
-f, --format [name] Font Awesome format version: accepts "latest", "v5-cjs", "v5-esm" (default: "latest")
-n, --namespace [name] Prepending the prefix, used as a namespace for UMD bundled index.js files. (default: "Awesomified")
-c, --clean cleans target directory first
-p, --prefix [name] sets icon prefix (default: "the")
-v, --has-variant [separator] use naming convention of [name][separator][variant] (default: -)
-e, --ensured-variants [variant 1]..[variant n] comma separated icon variants to always generate (default: [])
-h, --help output usage information
Can be used to gain better control over the behavior.
async function generate({
source = 'icons', // Relative or absolute path to SVGs to convert
target = 'dist', // Relative or absolute path to target directory
format = 'latest', // Which output Font Awesome format to use
namespace = 'Awesomify', // Prepending the prefix, used as a namespace for UMD bundled index.js files
deep = true, // Whether to deep scan the source directory for icons
cleanTarget = false, // Whether to wipe target first
prefix = 'the', // Set the prefix property on the icon entries any subdirectories will be appended to this inside the source
toBaseName = relativeName => relativeName, // Used for grouping icons if sized variants are used. Eg. to recognize user-small and user-large both as user, chop off the last bit
ensureVariants = _baseName => [] // Used to generate fallbacks for missing icons. Eg. to ensure user-16, user-32, and user-48 to exist, return them in an array
} = {}) {
Copyright 2014 - 2016 © taobao.org |