JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 34309
  • Score
    100M100P100Q182458F
  • License MIT

Pug loader module for Webpack

Package Exports

  • pug-loader

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pug-loader) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Pug loader for Webpack

Usage

var template = require("pug!./file.pug");
// => returns file.pug content as template function

var locals = { /* ... */ };

var html = template(locals);
// => the rendered HTML

For more information on how to use Webpack loaders, check the official documentation.

Legacy .jade files

pug-loader fully supports .jade files. Just use pug-loader with .jade files as you would with a .pug file.

Options

The following options are available to be set as part of the loader query. They are all mapped directly to Pug options, unless pointed out otherwise.

  • doctype
    • Unlike Pug, it defaults to "html" if not set
  • globals
  • self
  • plugins
    • Note that you cannot specify any Pug plugins implementing read or resolve hooks, as those are reserved for the loader
  • pretty
  • root
    • Webpack uses its own file resolving mechanism, so while it is functionally equivalent to the Pug option with the same name, it is implemented differently

Embedded resources

Try to use require for all your embedded resources, to process them with webpack.

div
  img(src=require("./my/image.png"))

Remember, you need to configure loaders for these file types too. You might be interested in the file loader.

License

MIT