Socket
Socket
Sign inDemoInstall

pug-package-loader

Package Overview
Dependencies
6
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    pug-package-loader

loader loading dependencies of pug templates, and pacakging


Version published
Maintainers
1
Install size
1.27 MB
Created

Readme

Source

pug-package-loader

loader loading dependencies of pug templates, and packaging all pug templates into one.

Install

npm install --save-dev pug-package-loader

Manageable Dependencies

pug template

include ../path/to/index.pug
extends ../path/to/index.pug

block [blockname]
block append [blockname]
block prepend [blockname]
append [blockname]
prepend [blockname]

pug inheritance refers to: https://pugjs.org/language/inheritance.html

attributes

img(src="../path/to/name.ext")
img(src='../path/to/name.ext')

as long as you config the pug-package-loader like this:

module.exports = {
  module: {
    rules: [{
      test: /\.pug$/,
      use: {
        loader: 'pug-package-loader',
        options: {
          attrs: [
            'img:src',
          ],
        },
      },
    }],
  },
};

Actually, by default options.attrs is [ 'img:src' ]. You can add custom <tag>:<attribute> like img:data-src, or combination without <tag> like :data-src.

If you don't need to process any relative path, just pass in attrs=false.

Usage

Below configuration is for webpack 4

module.exports = {
  module: {
    rules: [{
      test: /\.pug$/,
      use: {
        loader: 'pug-package-loader',
        options: {
          attrs: [
            // set your custom combinations
          ],
        },
      },
    }],
  },
};

You might be interested in file-loader, if you are handling image dependencies.

module.exports = {
  module: {
    rules: [{
      test: /\.(png|jpg|gif)$/,
      use: [
        {
          loader: 'file-loader',
          options: {
            name: 'img/[name].[hash:10].[ext]',
          },
        },
      ],
    }],
  },
};

Keywords

FAQs

Last updated on 23 Apr 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc