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 29, 2022
1 parent f09e678 commit fa0582e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 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!")


5 changes: 0 additions & 5 deletions app/javascript/packs/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
// To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate
// layout file, like app/views/layouts/application.html.erb

import { Turbo } from "@hotwired/turbo-rails"

// Disable turbo by default to avoid issues with turbolinks
Turbo.session.drive = false

import "../controllers/index"
import "trix"
import "@rails/actiontext"
Expand Down
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/[email protected]/dist/stimulus.js"
pin_all_from "app/javascript/controllers", under: "controllers"
pin "admin-lte", to: "https://ga.jspm.io/npm:[email protected]/dist/js/adminlte.min.js"
pin "jquery", to: "https://ga.jspm.io/npm:[email protected]/dist/jquery.js", preload: true
pin "@oddcamp/cocoon-vanilla-js", to: "https://ga.jspm.io/npm:@oddcamp/[email protected]/index.js"
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"@fullcalendar/luxon": "^5.11.0",
"@hotwired/stimulus": "^3.1.0",
"@hotwired/stimulus-webpack-helpers": "^1.0.1",
"@hotwired/turbo-rails": "^7.1.3",
"@rails/actiontext": "^7.0.2",
"@rails/webpacker": "5.4.3",
"actiontext": "https://github.com/rails/actiontext#archive",
Expand Down

0 comments on commit fa0582e

Please sign in to comment.