importmap-rails icon indicating copy to clipboard operation
importmap-rails copied to clipboard

Automatically add pinned files to assets.precompile

Open ankane opened this issue 2 years ago • 4 comments

Hi, I wanted to get thoughts on automatically adding pinned files to Rails.application.config.assets.precompile. I think it could eliminate complexity for both gem maintainers and gem users. Gem maintainers wouldn't need any additional engine code and gem users wouldn't need to remove assets if they're not using importmap-rails.

A few examples of complexity that could be eliminated:

ankane avatar Jan 07 '23 04:01 ankane

Maybe I'm misunderstanding, but isn't this already done here? https://github.com/rails/importmap-rails/blob/main/lib/importmap/engine.rb#L44-L46

dkniffin avatar Feb 17 '23 14:02 dkniffin

That adds the shim to the precompile list. If you comment out the highlighted lines in any of the gems above, you'll get Sprockets::Rails::Helper::AssetNotPrecompiledError.

ankane avatar Feb 17 '23 21:02 ankane

@ankane Ah, I see. This is mainly for gems. When you said pinned files, I thought you meant files inside the Rails app, which I believe are precompiled, since they are in app.config.assets.paths, right? I don't fully understand the difference between app.config.assets.paths and app.config.assets.precompile 🤔

dkniffin avatar Feb 20 '23 14:02 dkniffin

I'd be happy to see this.

dhh avatar Jun 18 '23 11:06 dhh