index.js
function loader(source) {

  // dust files don't have side effects, so loader results are cacheable
  if (this.cacheable) this.cacheable();

  // Set up default options & override them with other options
  const default_options = {
    root: '',
    dustAlias: 'dustjs-linkedin',
    namingFn: defaultNamingFunction,
    preserveWhitespace: false,
    wrapOutput: false,
    verbose: false,
    ignoreImages: false,
    excludeImageRegex: undefined
  };

  // webpack 4 'this.options' was deprecated in webpack 3 and removed in webpack 4
  // if you want to use global loader options, use dust-loader-complete < v4.0.0
  // var query = this.options || this.query || {};
  // var global_options = query['dust-loader-complete'] || {};

  // get user supplied loader options from `this.query`
  const loader_options = getOptions(this) || {};

  // merge user options with default options
  const options = Object.assign({}, default_options, loader_options);

  // Fix slashes & resolve root
  options.root = path.resolve(options.root.replace('/', path.sep));

  // Get the path
  const template_path = path.relative(options.root, this.resourcePath);

  // Create the template name
  const name = options.namingFn(template_path, options);

  // Log
  log(options, 'Loading DustJS module from "' + template_path + '": naming template "' + name + '"');

  // Find different styles of dependencies
  const deps = [];

  // Find regular dust partials, updating the source as needed for relatively-pathed partials
  source = findPartials(source, template_path + '/../', options, deps);

  // Find image dependencies
  if (!options.ignoreImages) {
    source = findImages(name, source, deps, options);
  }

  // Find require comments
  findRequireComments(source, template_path + '/../', options, deps);

  // Do not trim whitespace in case preserveWhitespace option is enabled
  dust.config.whitespace = options.preserveWhitespace;

  // Compile the template
  const template = dust.compile(source, name);

  // Build the returned string
  let returnedString;
  if (options.wrapOutput) {
    returnedString = "var dust = require('" + options.dustAlias + "/lib/dust'); "
      + deps.join(' ') + template
      + "var fn = " + defaultWrapperGenerator(name)
      + '; fn.templateName = "' + name + '"; '
      + "module.exports = fn;";
  } else {
    returnedString = "var dust = require('" + options.dustAlias + "'); "
      + deps.join(' ')
      + 'var template = ' + template + ';'
      + 'template.templateName = "' + name + '";'
      + "module.exports = template;";
  }

  // Return the string to be used
  return returnedString
}
function loader(source) {

  // dust files don't have side effects, so loader results are cacheable
  if (this.cacheable) this.cacheable();

  // Set up default options & override them with other options
  const default_options = {
    root: '',
    dustAlias: 'dustjs-linkedin',
    namingFn: defaultNamingFunction,
    preserveWhitespace: false,
    wrapOutput: false,
    verbose: false,
    ignoreImages: false,
    excludeImageRegex: undefined
  };

  // webpack 4 'this.options' was deprecated in webpack 3 and removed in webpack 4
  // if you want to use global loader options, use dust-loader-complete < v4.0.0
  // var query = this.options || this.query || {};
  // var global_options = query['dust-loader-complete'] || {};

  // get user supplied loader options from `this.query`
  const loader_options = getOptions(this) || {};

  // merge user options with default options
  const options = Object.assign({}, default_options, loader_options);

  // Fix slashes & resolve root
  options.root = path.resolve(options.root.replace('/', path.sep));

  // Get the path
  const template_path = path.relative(options.root, this.resourcePath);

  // Create the template name
  const name = options.namingFn(template_path, options);

  // Log
  log(options, 'Loading DustJS module from "' + template_path + '": naming template "' + name + '"');

  // Find different styles of dependencies
  const deps = [];

  // Find regular dust partials, updating the source as needed for relatively-pathed partials
  source = findPartials(source, template_path + '/../', options, deps);

  // Find image dependencies
  if (!options.ignoreImages) {
    source = findImages(name, source, deps, options);
  }

  // Find require comments
  findRequireComments(source, template_path + '/../', options, deps);

  // Do not trim whitespace in case preserveWhitespace option is enabled
  dust.config.whitespace = options.preserveWhitespace;

  // Compile the template
  const template = dust.compile(source, name);

  // Build the returned string
  let returnedString;
  if (options.wrapOutput) {
    returnedString = "var dust = require('" + options.dustAlias + "/lib/dust'); "
      + deps.join(' ') + template
      + "var fn = " + defaultWrapperGenerator(name)
      + '; fn.templateName = "' + name + '"; '
      + "module.exports = fn;";
  } else {
    returnedString = "var dust = require('" + options.dustAlias + "'); "
      + deps.join(' ')
      + 'var template = ' + template + ';'
      + 'template.templateName = "' + name + '";'
      + "module.exports = template;";
  }

  // Return the string to be used
  return returnedString
}
function loader ( source ) { // dust files don't have side effects, so loader results are cacheable if ( this . cacheable ) this . cacheable ( ) ; // Set up default options & override them with other options const default_options = { root : '' , dustAlias : 'dustjs-linkedin' , namingFn : defaultNamingFunction , preserveWhitespace : false , wrapOutput : false , verbose : false , ignoreImages : false , excludeImageRegex : undefined } ; // webpack 4 'this.options' was deprecated in webpack 3 and removed in webpack 4 // if you want to use global loader options, use dust-loader-complete < v4.0.0 // var query = this.options || this.query || {}; // var global_options = query['dust-loader-complete'] || {}; // get user supplied loader options from `this.query` const loader_options = getOptions ( this ) || { } ; // merge user options with default options const options = Object . assign ( { } , default_options , loader_options ) ; // Fix slashes & resolve root options . root = path . resolve ( options . root . replace ( '/' , path . sep ) ) ; // Get the path const template_path = path . relative ( options . root , this . resourcePath ) ; // Create the template name const name = options . namingFn ( template_path , options ) ; // Log log ( options , 'Loading DustJS module from "' + template_path + '": naming template "' + name + '"' ) ; // Find different styles of dependencies const deps = [ ] ; // Find regular dust partials, updating the source as needed for relatively-pathed partials source = findPartials ( source , template_path + '/../' , options , deps ) ; // Find image dependencies if ( ! options . ignoreImages ) { source = findImages ( name , source , deps , options ) ; } // Find require comments findRequireComments ( source , template_path + '/../' , options , deps ) ; // Do not trim whitespace in case preserveWhitespace option is enabled dust . config . whitespace = options . preserveWhitespace ; // Compile the template const template = dust . compile ( source , name ) ; // Build the returned string let returnedString ; if ( options . wrapOutput ) { returnedString = "var dust = require('" + options . dustAlias + "/lib/dust'); " + deps . join ( ' ' ) + template + "var fn = " + defaultWrapperGenerator ( name ) + '; fn.templateName = "' + name + '"; ' + "module.exports = fn;" ; } else { returnedString = "var dust = require('" + options . dustAlias + "'); " + deps . join ( ' ' ) + 'var template = ' + template + ';' + 'template.templateName = "' + name + '";' + "module.exports = template;" ; } // Return the string to be used return returnedString }
Main loader function
Main loader function