Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interaction of Tailwind and esbuild confusing in a new project created with phx.new #5912

Open
ponychicken opened this issue Aug 27, 2024 · 6 comments

Comments

@ponychicken
Copy link
Contributor

ponychicken commented Aug 27, 2024

I am not sure if this is a bug or needs to be documented better:
In a new project, there will be tailwind, taking care of generating the app.css and esbuild will generate the app.js

But if you add a new node dependency (in my case leaflet map) and its docs suggest to add some import calls to your js file in order to import necessary js and css, the setup breaks.

Once there is a call to import some css in app.js, esbuild will start generating an app.css as well. Which app.css will prevail is then just a question which one of the watchers got executed last. Anyway both the app.css generated from esbuild and the one generated from tailwind will be non funtional. the esbuild one will lack all tailwind classes, while the tailwind one will not have the styles that your library needs.

@SteffenDE
Copy link
Contributor

I wouldn't say that this is a bug, but it's definitely not nice behavior. The generators are meant to provide a sane default for getting started - anything relying on custom packages via node_modules is out of scope for them.

That being said, we could probably rename the app.css file into main.css to prevent conflicts if esbuild emits CSS as well. Then, we could add a section to the generated comment in app.js mentioning like:

// If you have dependencies that try to import CSS, esbuild will generate a separate `app.css` file.
// To load it, simply add a second `<link>` to your `root.html.heex` file.

Wdyt?

@ponychicken
Copy link
Contributor Author

I think that sounds like an elegant solution which doesnt require any in depth changes.

@quantuminformation
Copy link

new comer here making a youtube vid about all this, spent the last hour trying to remove tailwind with no luck, why this is a default? we don't even need it with css3

@Gazler
Copy link
Member

Gazler commented Sep 10, 2024

There is a --no-tailwind generator that can be used when creating the application. https://hexdocs.pm/phoenix/Mix.Tasks.Phx.New.html#module-options

@quantuminformation
Copy link

oh thats good to know thx

@josevalim
Copy link
Member

I like the main.css route too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants