caiocaio
Hi,
I wanted to get SASS working with Phoenix, but I just wasted my entire morning trying unsuccessfully to resolve npm dependencies (ie webpack 4.4 requires a package that requires webpack 4.36, and every attempt to fix is slow as molasses). Is there any way to use Phoenix without having to spend an inordinate amount of time of time messing around with npm or should I give up now?
Trending in Questions
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Hello,
I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind.
However, when I launch mix phx.server, I get an error...
New
I really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management servic...
New
I’m working on a small exercise involving update_in/3, and I came up with this solution:
data = %{
name: "Periodic Table",
category:...
New
Hello folks!
So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication):
toke...
New
Is there any way to avoid the Hologram compiler running when using iex? It seems like the front-end code could potentially be disregarded...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #metaprogramming











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
outlog
this one worked fine for me for adding Bulma over the weekend: https://phxroad.com/guides/add-bulma-fontawesome-and-sass-to-phoenix-using-webpack/
kokolegorille
Hello and welcome to the forum…
It’s mostly due to the ever moving js world. There is a post by @peerreynders here that explains how to procede with babel config. Don’t miss the ncu -u part, which is really cool tip to update your npm dependencies.
Don’t forget to add node-sass and sass-loader.
A good start would be to show part of your package.json and webpack.config.js.
These are rules I am using for sass, fonts, images… (in webpack.config.js)
l-vincent-l
I started something to do that it’s here, it uses sass-c GitHub - l-vincent-l/elixir-sass-reloader: Add this module to compile your sass file without webpack · GitHub
peerreynders
You can opt out of webpack with
--no-webpack.Opting out of
npmis a bit more problematic because you then have to be responsible for includingphoenix_html.jsandphoenix.js.Webpack isn’t an integral part of Phoenix but since Phoenix’s initial release it has included a bundler for convenience and to promote the use of modern modular JavaScript. Initially Phoenix included
brunchas a low-maintenance option but webpack has become the defacto standard with the React and Vue community, so Phoenix 1.4 switched to webpack due to popular demand. But nobody is forced to use webpack.And while SASS will probably remain the standard for complex projects there has been a noticable trend towards simply using modern CSS features like CSS custom properties and a handful of (Node.js powered) PostCSS plugins instead of full-blown SASS for more basic needs.
At the most basic level Phoenix will serve static assets out of
What is picked up from that folder is governed by
This default configuration will only pick up the
favicon.icoandrobots.txtfiles and whatever files are in thecss,fonts,images,jsfolders (Plug.StaticOptions).Given that knowledge you should be able to take full control over the content that is being served.
The one disadvantage is that you won’t have the convenience of live reloading during development. That is why the frontend development assets are kept under
The tooling there typically places any “refreshed” static assets under
so that it can be copied over to
when it is ready.
Phoenix starts the watch script to build the asset files with:
via that
watchersentry (Phoenix.EndpointRuntime configuration).Little bit further down in that same
dev.exs:Those
patternsdetermine what files will triggerPhoenix.LiveReloaderto force a refresh in your browser.This information should be enough for you to put together a frontend development environment of your own preference.
LostKobrakai
That’s not completely correct.
config :my_app, MyAppWeb.Endpoint, watchers: […]does only handle that e.g. the webpack watcher is started when phoenix is serving the endpoint. This is completely unrelated to live reloading, which only works based on the wildcards listed in:live_reload.Any external tool, which can put/update files in
priv/staticwill trigger live reloads.peerreynders
It is unrelated to
Phoenix.LiveReload- but it it is an integral part to the live reloading development cycle.Phoenix.LiveReloadwon’t have anything to do (frontend asset -wise) unless files in those directories are changed - (watching and) updating the static asset files is the responsibility of the script that is started bywatchers- so thewatchersconfiguration is an integral part of the live reloading development cycle even if that is part of thePhoenix.Endpointrather than thePhoenix.LiveReloadconfiguration.LostKobrakai
Not really. I could just as well edit a
style.cssfile manually inpriv/staticand it would be live reloaded. A watcher is only needed if there’s a compilation step to be done when source files are edited. For anyone working directly with the to-be-deployed assets this can be skipped completely.peerreynders
The OP is talking about using Sass.
In that situation the file edited would be an
.scssor.sassfile. A recurring theme in top 10 web development mistakes lists is not using automatic browser refresh when any of the development assets are being updated - that is what thewatchersconfiguration is for.A watcher script preparing (and copying) frontend assets is an essential ingredient in a modern web development workflow that aims to automate browser refreshes for development.
If your aim is to trigger an automatic browser refresh (i.e. live reload development) when any
.scssor.sassfile is modified then you need to configurewatchers.LostKobrakai
I’m not disputing that this is the better case, but I still doubt that insisting on the need on some kind of watcher controlled by phoenix is the only way to go. In the past I’ve had great success with tools like CodeKit, which bundles all the dirty details of compiling source files in an easy to use desktop app. Sure this is not great for workflows involving CI/CD, but such applications can still be viable solutions outside of those constraints. Not everybody needs/uses a project building workflow with all the bells and whistles. When aware of the potential downsides it can be perfectly fine to opt for simpler solutions.
peerreynders
Glad I could help you to stop wasting your time!