Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
bb2c336781 | ||
|
2fc72898d3 | ||
|
dbf0994650 | ||
|
b9745233ab | ||
|
225e6dea60 | ||
|
5bc85cfee3 | ||
|
1374a3a65a |
@@ -24,7 +24,7 @@ svg-iconset --source=assets/images/icons --result=icons
|
|||||||
```
|
```
|
||||||
Creates a file `icons-iconset.svg` in same folder
|
Creates a file `icons-iconset.svg` in same folder
|
||||||
### In Project
|
### In Project
|
||||||
```
|
```javascript
|
||||||
const SvgIconset = require('svg-iconset');
|
const SvgIconset = require('svg-iconset');
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
@@ -32,9 +32,13 @@ const config = {
|
|||||||
result: 'icons', // Required
|
result: 'icons', // Required
|
||||||
// This is optional for optimize files using SVGO plugins
|
// This is optional for optimize files using SVGO plugins
|
||||||
optimize: {
|
optimize: {
|
||||||
removeViewBox: true, // Will remove attribute viewBox (default true)
|
removeViewBox: true, // Will remove attribute viewBox
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new SvgIconset(config).createSet();
|
new SvgIconset(config).createSet();
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Additional
|
||||||
|
[Default SVGO optimisation config](https://github.com/DariusNorv/svg-iconset/wiki#default-svgo-configuration)
|
||||||
|
|
||||||
|
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@vkl/svg-iconset-builder",
|
"name": "@vkl/svg-iconset-builder",
|
||||||
"version": "1.0.0",
|
"version": "1.0.2",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "@vkl/svg-iconset-builder",
|
"name": "@vkl/svg-iconset-builder",
|
||||||
"version": "1.0.0",
|
"version": "1.0.2",
|
||||||
"description": "create iconset from separated svg icons",
|
"description": "create iconset from separated svg icons",
|
||||||
"main": "./dist/app.js",
|
"main": "./dist/app.js",
|
||||||
|
"types": "./dist/app.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"prepare": "npm run build",
|
"prepare": "npm run build",
|
||||||
|
@@ -30,7 +30,6 @@ export class SvgIconset {
|
|||||||
|
|
||||||
svgClean(this.config.source, this.svgoPlugin)
|
svgClean(this.config.source, this.svgoPlugin)
|
||||||
.then(optimizedResponse => {
|
.then(optimizedResponse => {
|
||||||
let idx = 0;
|
|
||||||
const ids = optimizedResponse.map(el => el.id);
|
const ids = optimizedResponse.map(el => el.id);
|
||||||
Promise.all(optimizedResponse.map(el => el.optimized))
|
Promise.all(optimizedResponse.map(el => el.optimized))
|
||||||
.then(resFiles => {
|
.then(resFiles => {
|
||||||
@@ -38,9 +37,8 @@ export class SvgIconset {
|
|||||||
createWriteStream(resultFile)
|
createWriteStream(resultFile)
|
||||||
.once('open', function (this: WriteStream) {
|
.once('open', function (this: WriteStream) {
|
||||||
try {
|
try {
|
||||||
const data = resFiles.map(res => res.data.replace(/<svg /, `<svg id="${ids[idx]}" `));
|
const data = resFiles.map((res, idx) => res.data.replace(/<svg /, `<svg id="${ids[idx]}" `));
|
||||||
this.write(`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">${data.join('')}</svg>`);
|
this.write(`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">${data.join('')}</svg>`);
|
||||||
idx++;
|
|
||||||
this.end();
|
this.end();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log('ERROR', err);
|
console.log('ERROR', err);
|
||||||
|
Reference in New Issue
Block a user