Skip to content

Commit

Permalink
Merge 04a58a0 into d907d73
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDancingCode committed Feb 27, 2018
2 parents d907d73 + 04a58a0 commit ba7d7c1
Showing 1 changed file with 72 additions and 72 deletions.
144 changes: 72 additions & 72 deletions README.md
Expand Up @@ -26,12 +26,12 @@ npm install --save-dev gulp-svg-sprite
Then, add it to your `gulpfile.js`:

```javascript
var gulp = require('gulp'),
svgSprite = require('gulp-svg-sprite');
var gulp = require('gulp'),
svgSprite = require('gulp-svg-sprite');

gulp.src('path/to/assets/*.svg')
.pipe(svgSprite( /* ... Insert your configuration here ... */ ))
.pipe(gulp.dest('out'));
.pipe(svgSprite(/* ... Insert your configuration here ... */))
.pipe(gulp.dest('out'));
```

**NOTICE**: By default, *svg-sprite* **doesn't send any files downstream** unless you configure it. There are tons of options available — please see below for [some basic examples](#basic-example). Also, you should possibly [take care of errors](#error-handling) that might occur.
Expand Down Expand Up @@ -60,23 +60,23 @@ With Gulp, there is no need to specifiy a **main output directory**, as the gene
In this very basic example, mostly default settings will be applied to create a traditional CSS sprite (bundle of SVG sprite and CSS stylesheet).

```javascript
var gulp = require('gulp'),
svgSprite = require('gulp-svg-sprite'),

// Basic configuration example
config = {
mode : {
css : { // Activate the «css» mode
render : {
css : true // Activate CSS output (with default options)
}
}
}
};

gulp.src('**/*.svg', {cwd: 'path/to/assets'})
.pipe(svgSprite(config))
.pipe(gulp.dest('out'));
var gulp = require('gulp'),
svgSprite = require('gulp-svg-sprite'),
// Basic configuration example
config = {
mode: {
css: { // Activate the «css» mode
render: {
css: true // Activate CSS output (with default options)
}
}
}
};

gulp.src('**/*.svg', { cwd: 'path/to/assets' })
.pipe(svgSprite(config))
.pipe(gulp.dest('out'));
```

The following files and directories are created:
Expand All @@ -103,35 +103,35 @@ The following example is a little more complex:
* We'll keep the intermediate SVG source files.

```javascript
var gulp = require('gulp'),
svgSprite = require('gulp-svg-sprite'),

// More complex configuration example
config = {
shape : {
dimension : { // Set maximum dimensions
maxWidth : 32,
maxHeight : 32
},
spacing : { // Add padding
padding : 10
},
dest : 'out/intermediate-svg' // Keep the intermediate files
},
mode : {
view : { // Activate the «view» mode
bust : false,
render : {
scss : true // Activate Sass output (with default options)
}
},
symbol : true // Activate the «symbol» mode
}
};

gulp.src('**/*.svg', {cwd: 'path/to/assets'})
.pipe(svgSprite(config))
.pipe(gulp.dest('out'));
var gulp = require('gulp'),
svgSprite = require('gulp-svg-sprite'),
// More complex configuration example
config = {
shape: {
dimension: { // Set maximum dimensions
maxWidth: 32,
maxHeight: 32
},
spacing: { // Add padding
padding: 10
},
dest: 'out/intermediate-svg' // Keep the intermediate files
},
mode: {
view: { // Activate the «view» mode
bust: false,
render: {
scss: true // Activate Sass output (with default options)
}
},
symbol: true // Activate the «symbol» mode
}
};

gulp.src('**/*.svg', { cwd: 'path/to/assets' })
.pipe(svgSprite(config))
.pipe(gulp.dest('out'));
```

The following files and directories are created:
Expand All @@ -156,28 +156,28 @@ out
Errors might always happen — maybe there are some corrupted source SVG files, the default [SVGO](https://github.com/svg/svgo) plugin configuration is too aggressive or there's just an error in *svg-sprite*'s code. To make your tasks more robust, you might consider using [plumber](https://github.com/floatdrop/gulp-plumber) and adding your custom error handling:

```javascript
var gulp = require('gulp'),
svgSprite = require('gulp-svg-sprite'),
plumber = require('gulp-plumber'),

// Basic configuration example
config = {
mode : {
css : {
render : {
css : true
}
}
}
};

gulp.src('**/*.svg', {cwd: ''})
.pipe(plumber())
.pipe(svgSprite(config))
.on('error', function(error){
/* Do some awesome error handling ... */
})
.pipe(gulp.dest('out'));
var gulp = require('gulp'),
svgSprite = require('gulp-svg-sprite'),
plumber = require('gulp-plumber'),
// Basic configuration example
config = {
mode: {
css: {
render: {
css: true
}
}
}
};

gulp.src('**/*.svg', { cwd: '' })
.pipe(plumber())
.pipe(svgSprite(config))
.on('error', function(error) {
/* Do some awesome error handling ... */
})
.pipe(gulp.dest('out'));
```


Expand Down

0 comments on commit ba7d7c1

Please sign in to comment.