Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/marlonmarcello/snowpack-plugin-pug

Pug template engine plugin for Snowpack.
https://github.com/marlonmarcello/snowpack-plugin-pug

pug snowpack snowpack-plugin-pug template-engine

Last synced: about 2 months ago
JSON representation

Pug template engine plugin for Snowpack.

Awesome Lists containing this project

README

        

# @marlonmarcello/snowpack-plugin-pug

This plugin adds support for the [Pug](https://pugjs.org/) template engine to [Snowpack](https://www.snowpack.dev/).

### Install

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

### Usage

Add `@marlonmarcello/snowpack-plugin-pug` to your [Snowpack config file](https://www.snowpack.dev/reference/configuration):

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

### Options

You can pass all default [Pug options](https://pugjs.org/api/reference.html#options) plus:

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

### Example

```js
// snowpack.config.js
{
"plugins": [
[
"@marlonmarcello/snowpack-plugin-pug",
{
"data": {
"meta": {
"title": "My website"
}
}
}
]
]
}
```

```pug
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`.
```js
// snowpack.config.js
{
mount: {
public: { url: '/', static: false },
src: { url: '/dist' },
}
}
```
For the discussion on this issue see [#4](https://github.com/marlonmarcello/snowpack-plugin-pug/issues/4#issuecomment-807180519)