I have an 'admin panel' type of gem that is a rails engine. Because it's an admin panel, it needs to have it's own views, javascript files, styles, and what not. It works great on rails 5, but I have to update it to rails 6. However, I can't seem to get webpacker configured correctly on the new rails engine.
I've tried following this guide:
https://github.com/rails/webpacker/blob/master/docs/engines.md
However, it still doesn't work. I'm at a point where I'm getting these errors:
The script from “http://localhost:3000/my-engine-packs/js/application-6a0d7886f9c50530c60b.js” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type.
and
Loading failed for the <script> with source “http://localhost:3000/my-engine-packs/js/application-6a0d7886f9c50530c60b.js”.
There's very little documentation I can find anywhere else about this. Rails 6 applications by default come with webpacker, but the same isn't true for the engines—at least not yet. I can manually add all the webpacker files, but then what? When I do that, I just get the aforementioned errors.
It's hard for me to comment without more specifics, but here is another issue discussing a similar problem: https://github.com/rails/webpacker/issues/2119
@jakeNiemiec
Thank you very much for the response. I'd like to give more information, but I don't know what specifics would be necessary in order to help you and others answer the question.
I think what I'll do is generate a new bare bones rails engine in which I try to implement webpacker in a manner very similar to the way I'm trying to implement now in my gem. That way, if there are obvious code errors, or anything else of the sort, it can be pointed out. I'll post the link to the GitHub repo.
And again, thank you for the issue reference, I'll look into it.
@jakeNiemiec
Okay, here is the repo:
https://github.com/angarc/my-engine
I followed the guide step by step exactly.
Also
In addition to the two errors I mentioned at the top of this issue, I'm also getting this error when I check my terminal logs:
ActionController::RoutingError (No route matches [GET] "/my-engine-packs/js/application-b11f9831de4c3646906f.js")
You might get a better answer from @zedtux in the other issue, this is uncharted territory for me. But nonetheless, give me some time to experiment with the gem ecosystem. Rails 6 will need a clear way to do this, but I currently only have context on the JS side of things.
The script from “http://localhost:3000/my-engine-packs/js/application-6a0d7886f9c50530c60b.js” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type.
Loading failed for the