Skip to content

Commit

Permalink
Migrate turbo from webpack to importmaps
Browse files Browse the repository at this point in the history
  • Loading branch information
edwinthinks committed Oct 28, 2022
1 parent f09e678 commit 033fdab
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
10 changes: 8 additions & 2 deletions app/javascript/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@
* all the interactions.
*/
import jQuery from 'jquery'
import 'admin-lte'
import "@oddcamp/cocoon-vanilla-js";
import { Turbo } from "@hotwired/turbo-rails"

window.jQuery = jQuery
window.$ = jQuery

import 'admin-lte'
import "@oddcamp/cocoon-vanilla-js";
// Disable turbo by default to avoid issues with turbolinks
Turbo.session.drive = false

console.log("Hello from importmap-rails!")


2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<title><%= content_for?(:title) ? yield(:title) : default_title_content %></title>
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<%= csrf_meta_tags %>
<%= javascript_include_tag 'application' %>
<%# javascript_include_tag 'application' %>
<%= stylesheet_link_tag 'application', media: 'all' %>
<%= raw fullstory_script(current_user: current_user) if Rails.env.production? %>
<%# javascript_pack_tag 'application' %>
Expand Down
3 changes: 3 additions & 0 deletions config/importmap.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Pin npm packages by running ./bin/importmap

pin "application", preload: true
pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true
pin "@hotwired/stimulus", to: "https://ga.jspm.io/npm:@hotwired/stimulus@3.1.0/dist/stimulus.js"
pin_all_from "app/javascript/controllers", under: "controllers"
pin "admin-lte", to: "https://ga.jspm.io/npm:admin-lte@3.2.0/dist/js/adminlte.min.js"
pin "jquery", to: "https://ga.jspm.io/npm:jquery@3.6.1/dist/jquery.js", preload: true
pin "@oddcamp/cocoon-vanilla-js", to: "https://ga.jspm.io/npm:@oddcamp/cocoon-vanilla-js@1.1.3/index.js"

0 comments on commit 033fdab

Please sign in to comment.