Eleventy: Require cache bust in watch mode

Created on 4 Dec 2018  路  8Comments  路  Source: 11ty/eleventy

My .eleventy.js file looks like this:

const form = require('./eleventy/shortcodes/form')

module.exports = eleventyConfig => {
  eleventyConfig.addShortcode('formInput', form.input)
  eleventyConfig.addShortcode('formTextarea', form.textarea)
  eleventyConfig.addShortcode('formRadios', form.radios)
})

I wanted to write shortcodes in a separate file because they're too many to put into the eleventy.js config file. The problem with this approach is eleventy's --watch mode doesn't perform cachebust (unless I'm mistaken?).

So, any updates I make to ./eleventy/shortcodes/form doesn't get watched. I'll have to restart the cli manually.

bug

Most helpful comment

Also just tried to fix this with config.addWatchTarget() but was unsuccessful. FWIW, our shortcodes are in the _includes directory, so eleventy is trying to run when we update them, even without adding addWatchTarget() but their js just seems cached.

All 8 comments

Ah, good call! This has implications for local dependencies used in #118 templates too (which I鈥檓 working on now).

Seems like https://www.npmjs.com/package/dependency-tree might be a good match for this if the speed is right?

(For the record there are two things being reported here鈥攚e do require cache-bust on the config file .eleventy.js but do not require cache-bust or watch dependencies used in the config file yet)

Unfortunately, I don't have a clue whether dependency-tree helps. This isn't my area of expertise 馃槗. Sorry I can't provide many suggestions!

No worries @zellwk just thinking out loud! 馃憤

Inspired by and in addition to this, I opened a feature request at #333. Upvote if you like that!

This will be included with upcoming v0.7.0.

I might be wrong but it still doesn't work even with watchTarget addition.

Also just tried to fix this with config.addWatchTarget() but was unsuccessful. FWIW, our shortcodes are in the _includes directory, so eleventy is trying to run when we update them, even without adding addWatchTarget() but their js just seems cached.

Was this page helpful?
0 / 5 - 0 ratings