Skip to content
This repository has been archived by the owner on May 3, 2019. It is now read-only.

Allow optional custom svgmin plugins #2

Merged
merged 2 commits into from
Feb 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var Elixir = require('laravel-elixir');

var config = Elixir.config;

Elixir.extend('svgstore', function(baseDir, output, filename) {
Elixir.extend('svgstore', function(baseDir, output, filename, plugins) {
config.svg = {
folder: 'svg',
outputFolder: 'svg'
Expand All @@ -24,13 +24,13 @@ Elixir.extend('svgstore', function(baseDir, output, filename) {
var prefix = path.basename(file.relative, path.extname(file.relative));

return {
plugins: [{
plugins: plugins || [{
cleanupIDs: {
prefix: prefix + '-',
minify: true
}
}]
}
};
}))
.pipe(svgstore())
.on('error', function (e) {
Expand Down
31 changes: 26 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,45 @@ elixir(function(mix) {

## Usage

By default, it will look for .svg files within ```resources/assets/svg/``` and outputs
```sprites.svg``` to ```public/svg/```.
By default, it will look for .svg files within ```resources/assets/svg/``` and output
```sprites.svg``` to ```public/svg/```, using the following [svgmin plugins](https://github.com/ben-eb/gulp-svgmin#plugins):

You can optionally pass a source directory, an output directory, and a custom filename:
```
...

plugins: [{
cleanupIDs: {
prefix: prefix + '-',
minify: true
}
}]
```

You can optionally pass custom arguments for:

- source directory
- output directory
- filename
- [svgmin plugins](https://github.com/ben-eb/gulp-svgmin#plugins)

```js
...

var svgminPlugins = [
{ removeUnknownsAndDefaults: false },
{ removeUselessStrokeAndFill: false },
{ collapseGroups: false }
];

elixir(function(mix) {
mix.svgstore('resources/assets/icons', 'public/sprites/', 'icons.svg');
mix.svgstore('resources/assets/icons', 'public/sprites/', 'icons.svg', svgminPlugins);
});
```

## In Your Blade Templates

If you started with a file called ```myicon.svg``` you can display that icon like this:


```html
<svg style="width: .75em; height: .75em">
<use xlink:href="svg/sprites.svg#myicon"/>
Expand Down