Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/marlonmarcello/snowpack-plugin-pug
- Owner: marlonmarcello
- License: mit
- Created: 2020-12-15T07:22:24.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-09-07T18:41:09.000Z (over 3 years ago)
- Last Synced: 2024-04-24T14:37:59.505Z (8 months ago)
- Topics: pug, snowpack, snowpack-plugin-pug, template-engine
- Language: JavaScript
- Homepage:
- Size: 44.9 KB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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)