---
tags: repos
templateEngineOverride: md
title: svgdir2sprite
description: Creates a spritesheet from a directory of svgs. 
date: 2019-01-03
---

[Fork from Gitlab](https://gitlab.com/gaiety/svgdir2sprite)

[![npm version](https://badge.fury.io/js/svgdir2sprite.svg)](https://www.npmjs.com/package/svgdir2sprite)

Creates a spritesheet from a directory of svgs. Can return the results directly or write to a spritesheet svg file. Node based and powered by [svg2sprite](https://github.com/mrmlnc/svg2sprite).

## As a Module

`npm install --save svgdir2sprite`

### Return SVG Spritesheet as String

``` javascript
const svgdir2sprite = require('svgdir2sprite');

svgdir2sprite('./src/svgs') // Async Promise
.then((svgContent) => console.log(svgContent));
```

### Write SVG Spritesheet to File

``` javascript
const svgdir2sprite = require('svgdir2sprite');

svgdir2sprite('./src/svgs', './build/spritesheet.svg');
```

## From the CLI

`npm install -g svgdir2sprite`

### Return SVG Spritesheet to the Console

``` shell
svgdir2sprite ./src/svgs
```

### Write SVG Spritesheet to File

``` sh
svgdir2sprite ./src/svgs ./build/spritesheet.svg
```

