In the local environment everything works fine, but when I try to run the deploy on Netlify, I get an error that I don’t have dart sass installed. Does anyone have any configuration suggestions on how I can resolve this on Netlify?
I have no good answer for you (I think I have seen someone doing this, and they will chime in, I’m sure),
But I had a look, and even the NPM library currently requires an extra step to manually download the binary, if I understand the setup.
If we have some Netlify people in here (I will try to find them if they don’t respond); This binary is now out of beta and it would be great if you (and Cloudflare and friends) installed this as part of your build image – and allowed people to select a version via a DARTSASS_VERSION or something.
Hi, thank you for the reply and also for opening an issue on Netlify. I will wait for their answer and I hope we have a solution soon now that dart sass embedded is in stable version.
I got the following answer from the Cloudflare Pages team via Discord:
Your best solution to this in future will probably be something like Prebuilt Assets. With that, you’ll control the build process, image, etc. and can do whatever you want there, and then just ship the final artifacts over to Pages at the end.
However, they have no ETA for when this will be available.
As for Vercel, with whom I’ve also asked about this subject, I have yet to receive a response.
For what it’s worth in this whole discussion, since we seem for now to be at mercy of the various Hugo-savvy hosting vendors where Embedded Dart Sass is concerned . . .
Using Dart Sass with Hugo • There’s no reason to wait for the good stuff • Until hosts allow Embedded Dart Sass in their build processes, here’s a not-too-hacky workaround for Sass-on-Hugo fans.
Very nice. For trying this with other vendors, am curious about where you found this for Netlify for inclusion in build.sh:
BIN_DIR=/opt/build/repo/node_modules/.bin
Edit: was able to get it to work in Vercel by using:
BIN_DIR=${pwd}/bin
However, similar efforts in Cloudflare Pages keep running into permissions errors. One discussion thread led me to believe that a build command of chmod +x build.sh && ./build.sh would solve that, but it hasn’t. This would suggest that, with CFP, the answer I quoted from them earlier in this thread is the operative one, unfortunately.
Edit #2: Thanks to an as-always-savvy @bep tip, was able to find a segment of the CFP path that allowed insertion, so this works: BIN_DIR=/opt/buildhome/.binrc/bin. I think I’ll leave it to the rest of you folks to figure out what other vendors do, but this covers the only three I ever use any more — CFP, Vercel, and Netlify.
Edit #3: OK, my curiosity overcame me and I tried it with Render, too. There, the operative line for making this work is:
BIN_DIR=/opt/render/project/src/.venv/bin
However… Render still doesn’t recognize a HUGO_VERSION environment variable, so it installs — as of this writing — Hugo 0.92.1 rather than accepting the 0.93.3 var setting I gave it. I asked Render to make that feature available, as with other hosts, nearly a year ago and they still haven’t implemented it.
Since I got responses indicating that people needed more information about the local installation of the Embedded Dart Sass binary, I added this today: