Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 2, 2022 01:55 am GMT

Configuring TravisCI for phoenix with dart-sass

After a couple of years with our full-stack PhoenixFramework app on production, there have been a constant: node-sass breaks a lot. Every couple of weeks not paying attention to node modules, resulted in security patches to apply, that where blocked by node-sass not being able to compile because some random reason.

When Phoenix 1.6 was released, with node and WebPack free asset build, We decided to plan the migration out of WebPack and the main motivator, was get rid of as many node dependencies as possible. At the end we keep some node modules, all related to bootstrap.

The process we follow was based on the documentation provided by:

https://github.com/phoenixframework/esbuild
https://github.com/CargoSense/dart_sass

The decision to use Dart Sass was due to the decision by the sass project to not add more features to it. Also, if we could get rid of the single binary dependency the causes the most issues, was a big plus.

Everything went smoothly, until we try to deploy.

Our infrastructure deploys to VMs in RackSpace. We use the Travis CI process to compile and deploy the application. We are able to just build a tar file that gets pushed and deployed to the RS servers with Capistrano. Very little dependencies on the server side, no build tools on there, no ruby, elixir or OTP installed, just basic Linux installation.

So we followed instructions and installed Linux Homebrew (linuxbrew):

before_install:  - /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"  - export PATH=/home/linuxbrew/.linuxbrew/bin:$PATH  - test -r ~/.bash_profile && echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> ~/.bashrc  - brew install sass/sass/sass

Which resulted in this error:

pub getBecause sass depends on cli_pkg ^2.1.0 which doesn't match any versions, version solving failed.

After some research I found the culprit:

https://github.com/sass/dart-sass/issues/1660

Tl;DR: A dart-sass dependency (cli_pkg) publish version 2.1.0, people start including it in their libraries, then retracted, so now dart-sass can't build the package.

So I start looking for alternatives, and my first try was override the tapped version on the because, why not?

 - brew tap sass/sass  - sed -i 's/archive\/1\.49\.10/archive\/1.49.9/' /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/sass/homebrew-sass/sass.rb  - sed -i 's/3887b89d99fd52e49e5a33ec78b3705a25a6267bd9f85c16fc85a6f4bdf154e5/0df1e9d5ff73a752fe864fac58d8a010c3a089b07d9ba9a05f54d493fd26af8b/' /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/sass/homebrew-sass/sass.rbAuthor

After realizing how terrible this is, and reading again the documentation from dart-sass I saw how clear they recommend using the prebuilt binaries, so I did that:

before_install:  - rvm install 'ruby-3.0.0'  - curl -L https://github.com/sass/dart-sass/releases/download/1.49.10/dart-sass-1.49.10-linux-x64.tar.gz > dart-sass-1.49.10-linux-x64.tar.gz  - tar -xvf dart-sass-1.49.10-linux-x64.tar.gz  - echo 'export PATH="$PATH:$HOME/build/amco/contentinator/dart-sass:$PATH"' >> ~/.bashrc

Which works great!

The issue was a problem for me from yesterday, today I found the workaround and by now the bug has been resolved. I haven't try again to use Linuxbrew, and probably I will not, I might just keep the standalone library and just write some task insdie capistrano to handle versioning.

The PR was pushed and my package-lock.json file wen't from 13k+ lines, to just 75.


Original Link: https://dev.to/javierg/configuring-travisci-for-phoenix-with-dart-sass-1l6g

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To