Caching Elm downloads on Netlify builds

Hello all,

Evan requested that people take some time to make sure their Elm downloads are being cached on their CI environments. I came up with a solution for Netlify builds.

Here’s what the change looks like in your netlify.toml config:

  publish = "./dist/"
-  command = "npm run build"
+  command = "export ELM_HOME=\"$NETLIFY_CACHE_DIR/elm\" && npm run build"

I updated the elm-pages-starter repo with that config for anybody who uses that template going forward:

The details

Here’s the before and after:

It’s nice to shave off a few seconds (on average) from the build, and make it more resilient in case there is ever an outage.

I’m sure there could be a more elegant solution here for how to set the environment variable in Netlify. I played around with it for a while and had trouble getting it to work writing it with this alternative that I saw in these docs:

  # doesn't seem to work

But that’s just a minor aesthetic issue. Otherwise, everything seems to be working smoothly!

Hope that’s helpful for others!


This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.