I am using importmap-rails
.
I have a common.js
file at app/javascript/controllers/center/staff_profiles/common.js
in importmap, i already pinned controllers using below
pin_all_from "app/javascript/controllers", under: "controllers"
In index.html
, I am calling common.js
like below
<%= content_for :page_specific_scripts do %>
<%= javascript_import_module_tag 'controllers/center/staff_profiles/common' %>
<% end %>
I have page_specific_scripts
in layouts
Everything is working as expected till this place.
I have another file app/javascript/controllers/shared/scroll.js
like below
export function handleScroll(){
-- scroll code
}
and i am calling this in another js file app/javascript/controllers/user/work.js
like below
import {handleScroll} from "../../shared/scroll";
document.addEventListener("turbo:load", function() {
handleScroll();
});
Then I got error in production which says https://myapp.com/assets/controllers/shared/scroll” was blocked because of a disallowed MIME type (“text/html”)
.
This is working in local env.
I am using Rails 7.2