/** * svg-icons-tools configuration file * ---------------------------- * all paths relative to the work directory * * More info at https://github.com/massimo-cassandro/svg-icons-tools * * run with (from the svg-icons-tools work dir): `npx iconsTools` * or specifing a path for the config file: `npx iconsTools --config path/to/config.mjs` * * All paths in this config object are relative to the folder containing the config file * */ const config = { /** * SVG to JSX components */ jsx: { /** * Source folders * * Every file with svg extension in these folders will be processed * Sub dirs are ignored. * the `fill` array must contains the icons that use the `fill` attribute * similarly, the `stroke` one must contains the icons that use the `stroke` attribute * It is possible to manage both types of icons at the same time, otherwise leave * them empty or remove the ones you don't need. * If you don't need this feature, just remove the whole `jsx` object */ source_folders: { fill: [], stroke: [] }, /** * Custom function to create each JSX icon file * * If not defined, the default function will be used. * See `src/jsx-icon-file-builder.mjs` for more details about function argument and values to be returned * * @example * custom_icon_builder: (parsed_svg) => { ... your code ... } */ custom_icon_builder: null, /* path to the folder where the jsx components will be saved */ dest_folder: '', /** * Clear dest_folder folder before save new files */ clearDestFolder: false, /** * path to jsx icons index file * * Optional file that contains all generated icons as named exports. * Leave empty o remove if you don't need it */ index_file: '', /** if not null, overrides the global `svgo_config` */ svgo_config: null }, /** * svg file to be optimized */ optimize: { /** * Source folders * * See comment at `jsx` for more details * Leave empty or remove the whole `optimize` obj if you don't need this feature */ source_folders: { fill: [], stroke: [] }, /* path to the folder where the optimized files will be saved */ dest_folder: '', /** * Clear dest_folder folder before save new files */ clearDestFolder: false, /** if not null, overrides the global `svgo_config` */ svgo_config: null }, /** * SVG as symbols * * Parameters to combine many svg files into a single svg file with symbols * If you don't need this feature, just remove the `symbols` object or leave paths empty */ symbols: { /** * Source folders * * Every file with svg extension in these folders will be processed * Sub dirs are ignored. * Leave empty or remove the whole `symbols` obj if you don't need this feature * * NB: stroke and fill icons are handled by adding some classes to the `symbol` tag. * The same goes for non-square icons. * Adding classes to the `symbol` tag is useful for styling icons with css, * but it is not a well documented feature and may not work as expected in all browsers. * Be aware of this if you plan to use this feature. */ source_folders: { fill: [], stroke: [] }, /* path of the processed svg file */ dest_file: '', /* if true, the xml declaration (`(<\/rect>)?/gmi, // phosphoricons raw /(<\/path>)?/gmi, // remixicons with 'pallets' option (and others) ], /** * Opacity classes for duotone icons * * Convert opacity values to predefined classes * the key is the decimal part of the opacity value (e.g.: 2 == 0.2), the value * is the class to be added in place of the opacity value. * The purpose of this feature is to convert the opacity values of duotone icons * to predefined classes, merging similar values to an unique class: * the script will assign the class whose key is the closest to the opacity value. * For example, both 0.2 and 0.26 opacity values are converted * to the class `duotone-light` (whose key is 2). You then only need to set the classes in your css. * NB: only opacity attributes applied to elements inside the svg tag will be considered. * If you don't want to use this feature, remove the `opacity_classes` object or leave it empty * * @example * opacity_classes: { * 2: 'duotone-light', * 4: 'duotone-medium', * 6: 'duotone-dark', * }, */ opacity_classes: {}, /** * Icon type classes * * Optional classes to be added to fill and or stroke icons * leave empty or remove if you don't need them * * @example * icon_type_class: { * fill: 'fill-icons', * stroke: 'stroke-icons', * }, */ icon_type_class: { fill: '', stroke: '' }, /** * Non-square icons classes * * Assign specific classes to non-square icons. * Assuming that all icons have the viewBox attribute, and that all viewboxes * origin is at 0 0, the script analizes all icons widths and heights * and detect those with non-square aspect ratio. * Then, the values are compared (after being rounded to two decimal places) * to find the closest aspect ratio among * those listed in the `non_square_icons_classes` array. The class corresponding * to the found value is then assigned to the icon. * The first value of each subarray of `non_square_icons_classes` is the aspect ratio * (width / height), the second is the class to be assigned. * If you don't want to use this feature, remove the `non_square_icons_classes` * array or leave it empty * * NB: Although aspect-ratio classes are added to `symbol` tags, this functionality * is not supported in SVGs with that element type. * * @example * non_square_icons_classes: [ * [ 3/4, 'ratio-3x4'], * [ 3/5, 'ratio-3x5'], * [ 2/3, 'ratio-2x3'], * ], */ non_square_icons_classes: [], /** * Console colors * * Colors for console output as defined in * The default colors work well on dark background terminals, if you have a light background terminal, you may * need to change the colors. */ console_colors: { error : 'bgRed', warning : 'red', success : 'bgGreen', info : 'yellow', infoDim : ['yellow', 'dim'], }, /** * LEGACY * Features mantained for compatibility reasons */ /** * Svg to scss variables * Generate scss variables from specified svg icons */ svg_to_scss: { /* icons to be converted to scss variables. * Paths of the svg files to be processed (relative to config file). * Icons will be parsed and optimized then converted to scss variables. * The variable names will be the same as the file names, without extensions * and parts removed as per the `remove_prefix` parameter. */ files: [], /* string to be prefixed to the variable names */ varname_prefix: 'icon-', /* if true, the svg files are converted to data urls */ convert_to_css_url: true, /* path of the generated scss file */ scss_icons_file: '_icons-svg.scss', } }; export default config;