diff --git a/README.md b/README.md index 42e12b9..0e259d0 100644 --- a/README.md +++ b/README.md @@ -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} + ] + } + } } ``` diff --git a/index.js b/index.js index a6905f9..86e1c6f 100644 --- a/index.js +++ b/index.js @@ -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); diff --git a/package.json b/package.json index db5511a..cfb241d 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "vue-template-compiler": "^2.0.0" }, "dependencies": { + "loader-utils": "^1.1.0", "svgo": "^0.7.2" } }