Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Enable and use import maps #3208

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,5 @@ end

# Use Redis for Action Cable
gem "redis", "~> 4.0"

gem "importmap-rails", "~> 1.1"
6 changes: 5 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ GEM
image_processing (1.12.2)
mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.17, < 3)
importmap-rails (1.1.5)
actionpack (>= 6.0.0)
railties (>= 6.0.0)
jbuilder (2.11.5)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
Expand Down Expand Up @@ -652,6 +655,7 @@ DEPENDENCIES
httparty
icalendar
image_processing
importmap-rails (~> 1.1)
jbuilder
jquery-rails
jquery-ui-rails
Expand Down Expand Up @@ -708,4 +712,4 @@ RUBY VERSION
ruby 3.1.2p20

BUNDLED WITH
2.3.21
2.3.24
2 changes: 2 additions & 0 deletions app/assets/config/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
//= link_tree ../images
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .css
//= link_tree ../../javascript .js
//= link_tree ../../../vendor/javascript .js
131 changes: 0 additions & 131 deletions app/assets/javascripts/application.js

This file was deleted.

4 changes: 4 additions & 0 deletions app/javascript/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
import ConfettiGenerator from "confetti-js";
let conf = new ConfettiGenerator(0);
console.log("Hello from importmap!")
4 changes: 3 additions & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
<%= 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' %>
<%# javascript_pack_tag 'application' %>
<%= javascript_importmap_tags %>
<%= stylesheet_pack_tag 'application' %>
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
Expand All @@ -22,6 +23,7 @@
<meta name="turbo-visit-control" content="reload" />
<meta name="turbo-cache-control" content="no-cache" />
<% end %>
<%= javascript_importmap_tags %>
</head>
<body
data-turbo="<%= @turbo %>"
Expand Down
4 changes: 4 additions & 0 deletions bin/importmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env ruby

require_relative "../config/application"
require "importmap/commands"
6 changes: 6 additions & 0 deletions config/importmap.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Pin npm packages by running ./bin/importmap

pin "application", preload: true
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"
pin "confetti-js", to: "https://ga.jspm.io/npm:[email protected]/dist/index.js"
Empty file added vendor/javascript/.keep
Empty file.