<commit_before>var svg = require('svgo');
var loaderUtils = require('loader-utils');
var compiler = require('vue-template-compiler');

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);

  var cb = this.async();

  svgo.optimize(content, function (result) {
    if (result.error) {
      return cb(result.error);
    }
    
    var compiled = compiler.compile(result.data, {preserveWhitespace: false});
    cb(null, "module.exports = {render: function () {" + compiled.render + "}};");
  });
};<commit_msg>Added ability to include path to SVG file (#14)<commit_after>const svg = require('svgo');
const loaderUtils = require('loader-utils');
const compiler = require('vue-template-compiler');

module.exports = function (content) {
  const options = loaderUtils.getOptions(this) || {};
  const query = loaderUtils.parseQuery(this.resourceQuery || '?');
  const svgo = new svg(options.svgo || {
    plugins: [{ removeDoctype: true }, { removeComments: true }],
  });

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

  const cb = this.async();

  svgo.optimize(content, (result) => {
    if (result.error) {
      return cb(result.error);
    }

    const compiled = compiler.compile(result.data, { preserveWhitespace: false });
    let component = `render: function () {${compiled.render}}`;

    if (options.includePath || query.includePath) {
      const filename = loaderUtils.interpolateName(this, '[path][name].[ext]', { context: this.options.context });
      component = `${component}, path:${JSON.stringify(filename)}`;
    }

    cb(null, `module.exports = {${component}};`);
  });
};
{'fraction_non_alphanumeric': 0.1693121693121693, 'fraction_numerical': 0.0010582010582010583, 'mean_word_length': 4.238227146814404, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1927975', 'n_tokens_mistral': 591, 'n_tokens_neox': 573, 'n_words': 122}