dojap
I am using the new Phoenix 1.6 - installed from scratch.
in my css which is in assets/css/app.css
I have this line:
background-image: url(images/blue.png);
but I am getting this error:
error: Could not resolve “images/blue.png” (mark it as external to exclude it from the bundle)
the image is there, in priv/static/images/blue.png
Direct linking to the image from heex works, for example, this will show my image correctly:
<img src="/images/blue.png">
Any idea what is wrong?
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
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
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
experimentix
try this
background-image: url(“../images/blue.png”);
dojap
Thanks, I have tried but not working. Still the same error. If I comment out the background-image property everything goes fine. However, I need to use backgound images in my css ;).
Any idea what could be the culprit. In 1.5 it worked.
dojap
It is weird, I can successfully access the image from a browser like:
http://localhost:4000/images/blue.pngand the browser will show it.
But in app.css nothing works, no matter if I try:
After each I tried restarted the server via mix phx.server
Nothing works ;(
The css is loaded and working. All colors and styling works as it supposed to work, except the image via the background-image property.
When I try to use the absolute path:
background-image: url("http://localhost:4000/images/blue.png");It works and image is shown on the page, together with other things from the css etc.
So, only the relative path is not working for some reason.
Any idea what is going on?
dojap
Any idea what could be the problem why relative paths in CSS don’t work in Phoenix 1.6?
kip
Would you mind showing what your
Plug.Staticconfiguration is?cssrelative URL paths are relative to the location from which thecssfile itself was loaded. From your description it would seem that the location for thecssfile is different to the location of your images.dojap
This is what I have there:
My images folder, which is whitelisted in “only” as well, contains blue.png .
dojap
This must be something with esbuild, because if I manually edit the css file in priv/static/assets/app.css the image is shown no problem.
So, when I save the full path in assets/css/app.css like:
and run mix phx.server
it correctly puts the generated css file in priv/static/assets/app.css
Then when I edit this newly generated file and change that line to:
and save I see:
[debug] Live reload: priv/static/assets/app.css
in my console and the image appears normally.
Any idea why esbuild is not working?
Could it have something to do with my operating system? Does esbuild have different paths on Linux (Kubuntu 20.04 in my case) than other OSes, perhaps? Or what else could cause this issue?
Or perhaps it’s too nested? My project is 6 directories deep from the /home directory on my Kubuntu, so it is something like this:
/home/me/Devel/Personal/MB/mb-local-2021-elixir-1-6---active/mb/myblog/priv/static/dojap
This is getting insane.
I have just tried to create completely new installation of Phoenix 1.6 and it still doesn’t work.
Exactly what I did:
I went to my root of my home folder in Kubuntu 20.04 to eliminate the possible too-nested directories problem.
I run:
mix phx.new my_blog --liveConfirmed fetch and install dependencies question.
Then:
cd my_blogand
mix ecto.createand the DB was successfully created.
Then I run:
mix phx.serverand I now can successfully see the website on localhost:4000
So far, as expected. No problems.
Now, I went into this directory:
assets/css/and opened this file:
phoenix.cssIn this file I changed this:
into this:
and then I stopped the server via CTRL+C pressed twice and then
started it again:
mix phx.serverAnd I got no image shown on the website and this error in the terminal console:
At this point I don’t know what more to do.
Please, try to replicate these steps with the fresh Phoenix 1.6 install and let me know if you got the same result.
Thank you a lot in advance.
dojap
Hmm, I don’t know how to debug it.
I am currently reading this CSS: resolve relative paths without ./ prefix · Issue #469 · evanw/esbuild · GitHub and Different absolute/relative css image url path resolution between Windows and Linux · Issue #822 · evanw/esbuild · GitHub but I don’t know if it helps.
It’s very weird that nobody else encountered this problem before.
bartblast
Shouldn’t the path be relative to the location of the file during compilation?
Did you try:
background-image: url(“../../priv/static/images/blue.png”);