snowpack-plugin-pug

1.0.6 • Public • Published

@marlonmarcello/snowpack-plugin-pug

This plugin adds support for the Pug template engine to Snowpack.

Install

npm install --save-dev @marlonmarcello/snowpack-plugin-pug

Usage

Add @marlonmarcello/snowpack-plugin-pug to your Snowpack config file:

{
  "plugins": ["@marlonmarcello/snowpack-plugin-pug"]
}

Options

You can pass all default Pug options plus:

  • data: object - Any data that you would like available globaly to templates

Example

// snowpack.config.js
{
  "plugins": [
    [
      "@marlonmarcello/snowpack-plugin-pug",
      {
        "data": {
          "meta": {
            "title": "My website"
          }
        }
      }
    ]
  ]
}
doctype html
html(lang="en")
  head
    meta(charset="UTF-8")
    meta(name="viewport", content="width=device-width, initial-scale=1.0")
    title!=meta.title
  body
    //- template

create-snowpack-app

If you've used create-snowpack-app to bootstrap your project you might have a src/ and a public/ directory.
By default, the /public directory is set up as static, so Pug files there won't be compiled to HTML files.
The solution is to change the /public directory to not be static in snowpack.config.js.

// snowpack.config.js
{
  mount: {
    public: { url: '/', static: false },
    src: { url: '/dist' },
  }
}

For the discussion on this issue see #4

Dependencies (1)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i snowpack-plugin-pug

    Weekly Downloads

    1

    Version

    1.0.6

    License

    MIT

    Unpacked Size

    7.84 kB

    Total Files

    6

    Last publish

    Collaborators

    • cekvenich