Need private packages and team management tools?Check out npm Teams »


5.0.1 • Public • Published


A complete webpack loader for DustJS files.


dust-loader-complete is a webpack loader for DustJS files that compiles DustJS template files into their JavaScript template functions. It has a couple of features that distinguish it from the alternatives:

  1. It finds all partials and requires them, which adds them into your webpack bundle.
  2. It finds <img> tags and resolves the images specified in the src (see options below to disable or filter which paths are resolved).
  3. It adds a templateName to the compile template function which can be easier to pass around your application if needed.


    npm install --save-dev dust-loader-complete dustjs-linkedin


There are two changes you need to make to your webpack configuration in order to use dust-loader-complete.

First, add the following to the array of loaders (assuming your dust files are saved with a .dust extension):

    { test: /\.dust$/, loader: "dust-loader-complete" }

Second, provide an alias for the dustjs-linkedin module. dust-loader-complete writes a var dust = require( ) method at the top of every compiled template. It needs to know how to require the DustJS module. The default is to use the alias dustjs:

    alias: {
        dustjs: 'dustjs-linkedin'


If you want to use NPM's dustjs-helpers module, you'll have to add the following alias:

    alias: {
        'dust.core': 'dustjs-linkedin'


dust-loader-complete offers several options to customize its behavior. Read the loader documentation to learn more about how to set loader options.


Set a root path for your dust templates. This root will be removed from the beginning of the dust module path before it is turned into the template name via the namingFn.


Set this to true to skip the resolving of image dependencies from your dust templates.


Set this to a Regex if you want to exclude some image paths from being resolved. If the contents of the src attribute match the Regex, the image tag will not be processed.


If you've set up an alias for dustjs-linkedin, you can use this option to instruct the loader to use the same alias.


Set preserveWhitespace: true to disable whitespace trimming. By default DustJS trims all whitespace before compiling a template, enabling this option will prevent this.

wrapperGenerator (prior to 3.0.0 only)

This option must be set via the "global" configuration object. What this means is that in your webpack configuration object, create a top-level object with the name `dust-loader-complete':

        entry: '/path/to/entry.js',
        'dust-loader-complete': {
            wrapperGenerator: function ( name ) { .... }

This function generates the dust.render wrapper function. It receives a single parameter, the template name as a string, and it must return a string that when written out to the webpack JavaScript file will render the dust template. For example, the default function is

    function defaultWrapperGenerator( name ) {
      return "function( context, callback ) { dust.render( '" + name + "', context, callback ); }";


Set wrapOutput: true to turn on the defaultWrapperGenerator from above.


Set verbose: true to see console logs from dust-loader-complete


npm i dust-loader-complete

DownloadsWeekly Downloads






Unpacked Size

1.62 MB

Total Files


Last publish


  • avatar