Created
May 15, 2024 10:12
-
-
Save aamnah/87b1aad1bfbd08d2267c26e099c25024 to your computer and use it in GitHub Desktop.
Install embedded dart sass on Netlify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script was originally written so i could deploy Hugo sites to Netlify that were using Embedded Dart Sass to compile. | |
# This script is no no longer needed for the purpose above. | |
# NOTES | |
# - no point in adding line breaks in echo, Netlify logs disregard them | |
# refs | |
# - https://discourse.gohugo.io/t/using-dart-sass-hugo-and-netlify/37099/13 | |
# - https://github.com/bep/hugo-dartsass-testrepo/blob/main/build.sh | |
# add this to git with `git add --chmod=+x build.sh .` | |
# or chmod before you git `chmod +x build.sh && ./build.sh` git preserves the chmod bits | |
# Otherwise you'll get error: `bash: ./build.sh: Permission denied` | |
# Update Dart Sass Embedded Version to whatever is the latest | |
# https://github.com/sass/dart-sass-embedded/releases | |
DARTSASS_VERSION="1.62.1" | |
# This BIN_DIR will be in Netlify's PATH. | |
BIN_DIR="/opt/build/repo/node_modules/.bin" # Netlify | |
# BIN_DIR=${pwd}/bin # Vercel | |
# BIN_DIR=/opt/buildhome/.binrc/bin # Cloudflare Pages | |
log() { | |
COLOR_MAGENTA="\u1b[35m" | |
COLOR_OFF="\033[m" | |
echo -e "${COLOR_MAGENTA}==== ${1} ...${COLOR_OFF}" | |
} | |
install_dart_sass_embedded() { | |
# log "PATH is" | |
# echo ${PATH} | |
log "Installing Dart Sass Embedded" | |
mkdir -p ${BIN_DIR} | |
curl -LJO https://github.com/sass/dart-sass-embedded/releases/download/${DARTSASS_VERSION}/sass_embedded-${DARTSASS_VERSION}-linux-x64.tar.gz; | |
tar -xvf sass_embedded-${DARTSASS_VERSION}-linux-x64.tar.gz; | |
mv sass_embedded/* ${BIN_DIR} | |
rm -rf sass_embedded*; | |
# log "List Bin Dir contents" | |
# ls ${BIN_DIR}; | |
log "dart-sass-embedded successfully installed" | |
dart-sass-embedded --version | |
} | |
build_site() { | |
log "Building site" | |
# update all Hugo modules | |
hugo mod get -u | |
# build site | |
hugo --buildDrafts --gc --minify | |
} | |
deployment_details(){ | |
# Log Netlify deployment URLs | |
# https://docs.netlify.com/configure-builds/environment-variables/#deploy-urls-and-metadata | |
log "Site deployed" | |
log "${DEPLOY_URL}" | |
log "${DEPLOY_PRIME_URL}" | |
} | |
# Execute | |
install_dart_sass_embedded | |
build_site | |
deployment_details |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment