Use Node Modules in Eleventy

Use Passthrough File Copy to, well, pass them through.

Fri, 01 Apr 2022 | Reading Time: 1 minute

When I started my Eleventy journey, I was still very new to web development. I'd see posts about cool CSS resets or script packages and want to use them, only to be stumped on how to get from npm i to using it in my static site website.

Well, this month I was doing some Googling on something I've already forgotten and found an issue in the 11ty repo where someone asked this exact question, months before I needed it.

The solution? Eleventy's Passthrough File Copy.

// Zach's answer from the GitHub issue
"node_modules/chartist/dist/chartist.min.css": "assets/chartist.min.css",
"node_modules/chartist/dist/chartist.min.js": "assets/chartist.min.js"

If only I knew how to properly Google code questions back then. Hopefully someone else may find this useful.


No mentions yet ¯\_(ツ)_/¯