Attempting to integrate my CSS and JavaScript codes into 11ty has been a bit challenging for me. I recently discovered that 11ty utilizes something called .11ty.js, so I decided to utilize the addPassthroughCopy()
function.
Below is the script I tried:
module.exports = function (eleventyConfig) {
eleventyConfig.addPassthroughCopy("data/mainStyle.css");
return
dir: {
passthroughFileCopy: true
}
};
However, when attempting to compile using npx @11ty/eleventy, I encountered an error message:
[11ty] Problem writing Eleventy templates: (more in DEBUG output)
[11ty] 1. Having trouble rendering 11ty.js template ./.11ty.js (via TemplateContentRenderError)
[11ty] 2. eleventyConfig.addPassthroughCopy is not a function (via TypeError)
[11ty]
[11ty] Original error stack trace: TypeError: eleventyConfig.addPassthroughCopy is not a function
[11ty] at module.exports [as render] (C:\Users\User\Desktop\website\.11ty.js:2:20)
[11ty] at JavaScript.<anonymous> (C:\Users\User\node_modules\@11ty\eleventy\src\Engines\JavaScript.js:144:43)
[11ty] at Template._render (C:\Users\User\node_modules\@11ty\eleventy\src\TemplateContent.js:507:28)
[11ty] at async Template.renderWithoutLayout (C:\Users\User\node_modules\@11ty\eleventy\src\Template.js:456:27)
[11ty] at async TemplateMap.populateContentDataInMap (C:\Users\User\node_modules\@11ty\eleventy\src\TemplateMap.js:585:39)
[11ty] at async TemplateMap.cache (C:\Users\User\node_modules\@11ty\eleventy\src\TemplateMap.js:479:5)
[11ty] at async TemplateWriter._createTemplateMap (C:\Users\User\node_modules\@11ty\eleventy\src\TemplateWriter.js:330:5)
[11ty] at async TemplateWriter.generateTemplates (C:\Users\User\node_modules\@11ty\eleventy\src\TemplateWriter.js:360:5)
[11ty] at async TemplateWriter.write (C:\Users\User\node_modules\@11ty\eleventy\src\TemplateWriter.js:407:23)
[11ty] at async Eleventy.executeBuild (C:\Users\User\node_modules\@11ty\eleventy\src\Eleventy.js:1160:13)
[11ty] Wrote 0 files in 0.04 seconds (v2.0.0)
I attempted removing the eleventyconfig.addpassthroughcopy and it did solve the issue, but I still need to include the CSS into my script. Can anyone provide guidance?
Even trying eleventyconfig.passthroughcopy led to the same result.