fix: Remove unecessary whitespace from SVG contents

```js
/* BEFORE */
{ circle: "\n  <circle cx=\"12\" cy=\"12\" r=\"10\"></circle>\n" }

/* AFTER */
{ circle: "<circle cx=\"12\" cy=\"12\" r=\"10\"></circle>" }
```
This commit is contained in:
Cole Bemis
2017-11-19 16:29:52 -08:00
committed by GitHub
parent b814a2b94b
commit c9552b6916
4 changed files with 115 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
/* eslint-disable import/no-extraneous-dependencies */
import path from 'path';
import cheerio from 'cheerio';
import { minify } from 'html-minifier';
/**
* Build an object in the format: `{ <name>: <contents> }`.
@@ -28,7 +29,7 @@ function buildIconsObject(svgFiles, getSvg) {
*/
function getSvgContents(svg) {
const $ = cheerio.load(svg);
return $('svg').html();
return minify($('svg').html(), { collapseWhitespace: true });
}
export default buildIconsObject;