Ask A Question

Notifications

You’re not receiving notifications from this thread.

Separate JavaScript Importmaps For Rails Engines Discussion

Good stuff! I have an idea for another episode/lesson:
When using TailwindCSS (which is pretty much the standard nowadays) in an Rails app, I found myself wanting to build "plugins" or extended functionality nby using engines. I would be very cool to have a way to automatically scan the views in the engine when creating the TailwindCSS output (using the TailwindConfig from the main app). I've seen some examples that precompiles a css-bundle in the engine and then include it in the main app.

Maybe this is a solved problem? :)

Reply

To do that, you'd need to have a way to dynamically add the engine folders to the tailwind.config.js in the parent app. That runs Node, but you could probably have it run a Rails command to get a list of folders that you parse an add to the content: [] dynamically.

The main reason for keeping separate, precompiled CSS for engines is that they don't require the parent app to run Tailwind or any other framework that way.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 87,110+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.