1.0.7 • Published 4 years ago
snowpack4-plugin-pug v1.0.7
@marlonmarcello/snowpack-plugin-pug
This plugin adds support for the Pug template engine to Snowpack.
Install
npm install --save-dev @marlonmarcello/snowpack-plugin-pugUsage
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
//- templatecreate-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
1.0.7
4 years ago