I’ve been using nested CSS but I need to support older browsers. My Phoenix app uses the default Esbuild setup, so I looked for support for unnesting CSS.
# Configure esbuild (the version is required)
config :esbuild,
version: "0.19.11",
default: [
args:
~w(js/app.js --bundle --target=es2017,chrome88,edge109,firefox115,safari11 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*),
cd: Path.expand("../assets", __DIR__),
env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
]
I set the version to 0.19.11 because I noticed some changes to how nested CSS is parsed in versions after 0.17.14.
I also included import '../css/app.css'; in my js/app.js after reading the Esbuild docs about CSS, because otherwise the CSS was still not flattened. Not sure why.
This was after I successfully flattened the nested CSS in local development, after the help in this Elixir Forum topic. In production with Fly.io it did not work. Not yet, at least. Also after trying version 0.17.18.
Edit: Ah, re-read this. If it successfully worked in dev and not in prod, there must a difference in the esbuild configuration between the two environments?
Maybe try just using the “es2016,chrome58”, drop the rest, and see how it is on Safari? That has worked for me when I converted from scss to vanilla css with variables and I haven’t had any issues with real iphones/ipads.