javascriptmodulenunjuckseleventy

Eleventy addPassthroughCopy for Javascript folder doesn't copy files


Probably I'm missing something completely obvious. I tried to pass through my main.js file but nothing seems to work.

module.exports = function (eleventyConfig) {
    eleventyConfig.addPassthroughCopy("./src/assets/js");
    eleventyConfig.addWatchTarget("./src/assets/");
  
    return {
      dir: {
        input: "src",
        output: "public",
      },
    };
  };

My folder structure is set up as follows

📦eleventy-project
 ┣ 📂src
 ┃ ┣ 📂_includes
 ┃ ┃ ┗ 📜base.njk
 ┃ ┣ 📂assets
 ┃ ┃ ┗ 📂js
 ┃ ┃   ┗ 📜main.js
 ┃ ┗ 📜index.njk
 ┣ 📜.eleventy.js
 ┣ 📜package-lock.json
 ┗ 📜package.json

Everything else works. The target watch works, input and output directories work but the passthroughCopy doesn't do anything.

Does anybody see my mistake?


Solution

  • Okay, stupid me. The passthrough seems only to take effect on build not on serve (at least in 11ty 2.0). Site works, it just copies the files only on build.