11ty-website icon indicating copy to clipboard operation
11ty-website copied to clipboard

Nunjucks own environment watching

Open acurrieclark opened this issue 5 years ago • 0 comments

While I realise that the example given in the docs for passing in your own instance of a Nunjucks Environment is purely illustrational, I spotted it as the solution for trimming down my {% include long/path/goes/here.html %} paths.

What I didn't realise (until I delved into the very sensibly linked docs) is that any changes to files in this path are not reflected when Eleventy spots a change unless the optional watch property is set to true.

Might I suggest a small change?

  let env = process.env.ELEVENTY_ENV;

  let nunjucksEnvironment = new Nunjucks.Environment(
    new Nunjucks.FileSystemLoader("_includes", {
      watch: env == "development"
    })
  );

Happy to submit a pull request if this might be a good idea.

acurrieclark avatar Dec 02 '19 16:12 acurrieclark