Git Product home page Git Product logo

snowpack-plugin-nunjucks's Introduction

snowpack-plugin-nunjucks

npm

Use Nunjucks to build .njk files from source.

Usage

From a terminal, run the following:

npm install --save-dev snowpack-plugin-nunjucks

Then add this plugin to your Snowpack config:

// snowpack.config.json
{
  "plugins": [
    "snowpack-plugin-nunjucks"
  ]
}

snowpack-plugin-nunjucks's People

Contributors

mxmul avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

maartenth

snowpack-plugin-nunjucks's Issues

Trouble extending from templates

I integrated snowpack-plugin-nunjucks 0.0.3 in a brand new "core Web" project. My snowpack.config.js is quite simple:

/** @type { import("snowpack").SnowpackUserConfig } */
export default {
  devOptions: {
    open: "none",
  },
  env: {
    // ...
  },
  mount: {
    src: {
      url: "/",
    },
  },
  optimize: {
    bundle: true,
    minify: true,
    target: "es2018",
  },
  plugins: [
    "@snowpack/plugin-webpack",
    "snowpack-plugin-nunjucks",
  ],
};

Within src I've started to put together all the pieces, so I have an index.njk:

{% set title = "Home" %}

// Notice that files must be referenced from the project's root
{% extends "src/_layout.njk" %}

...

After I run Snowpack's build, I still see the Nunjucks templates (prefixed by _file_name.[ext], for instance, _layout.njk) being "generated" inside build.

I believe those files should be excluded, right? Only those .njk or .html files within src that aren't prefixed with _ should be processed and finally copied over into build.

Snowpack does not recognize Nunjucks template in `development` mode

Me again ๐Ÿ‘‹๐Ÿป

I have the same simple project. Basically some .njk files in the project's root. When snowpack dev is executed the server starts correctly and so on, but when I browse over the exposed address (typically http://localhost:8080) the default entry point (index.html) is not recognized as HTML, but as application/octet-stream.

As a result, what I get is a prompt to download a file, which in turn, has the correct content (from index.html), but somehow it's not recognized automatically by the browsers as such.

Could it be that the integration with the plugin and Snowpack is not quite there yet, or do you think this is something that I might have misconfigured on my end โ€” I'm quite new to Snowpack ๐Ÿ˜‡

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.