Skip to content

Commit

Permalink
Merge pull request #11 from matpeder/master
Browse files Browse the repository at this point in the history
Add svgo options (thank you @matpeder!)
  • Loading branch information
visualfanatic authored Oct 22, 2017
2 parents ff84278 + 767d66b commit 27b2f53
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ yarn add --dev vue-template-compiler vue-svg-loader
{
test: /\.svg$/,
loader: 'vue-svg-loader', // `vue-svg` for webpack 1.x
options: {
// optional [svgo](https://github.com/svg/svgo) options
svgo: {
plugins: [
{removeDoctype: true},
{removeComments: true}
]
}
}
}
```

Expand Down
11 changes: 7 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
var svg = require('svgo');
var loaderUtils = require('loader-utils');
var compiler = require('vue-template-compiler');

var svgo = new svg({
plugins: ['removeDoctype', 'removeComments'],
});

module.exports = function (content) {
var options = loaderUtils.getOptions(this) || {};
var svgoOptions = options.svgo || {
plugins: [{removeDoctype: true}, {removeComments: true}],
};
var svgo = new svg(svgoOptions);

this.cacheable && this.cacheable(true);
this.addDependency(this.resourcePath);

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"vue-template-compiler": "^2.0.0"
},
"dependencies": {
"loader-utils": "^1.1.0",
"svgo": "^0.7.2"
}
}

0 comments on commit 27b2f53

Please sign in to comment.