Created
August 27, 2019 13:55
-
-
Save inopinatus/4bfc014163280783e38ec478d7e49e97 to your computer and use it in GitHub Desktop.
Re-enable sprockets handling JS in Rails 6.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Gemfile b/Gemfile | |
index 79cc614..9e03100 100644 | |
--- a/Gemfile | |
+++ b/Gemfile | |
@@ -11,6 +11,8 @@ gem 'sqlite3', '~> 1.4' | |
gem 'puma', '~> 3.11' | |
# Use SCSS for stylesheets | |
gem 'sass-rails', '~> 5' | |
+# Bring back uglifier for sprockets | |
+gem 'uglifier', '>= 1.3.0' | |
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker | |
gem 'webpacker', '~> 4.0' | |
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks | |
@@ -28,6 +30,9 @@ gem 'jbuilder', '~> 2.7' | |
# Reduces boot times through caching; required in config/boot.rb | |
gem 'bootsnap', '>= 1.4.2', require: false | |
+# Add your obsolete gems etc | |
+gem 'momentjs-rails' | |
+ | |
group :development, :test do | |
# Call 'byebug' anywhere in the code to stop execution and get a debugger console | |
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] | |
diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js | |
index 5918193..b16e53d 100644 | |
--- a/app/assets/config/manifest.js | |
+++ b/app/assets/config/manifest.js | |
@@ -1,2 +1,3 @@ | |
//= link_tree ../images | |
+//= link_directory ../javascripts .js | |
//= link_directory ../stylesheets .css | |
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js | |
new file mode 100644 | |
index 0000000..9c488fb | |
--- /dev/null | |
+++ b/app/assets/javascripts/application.js | |
@@ -0,0 +1,2 @@ | |
+//= require moment | |
+//= require_tree . | |
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb | |
index 32d9bc1..e721dc9 100644 | |
--- a/app/views/layouts/application.html.erb | |
+++ b/app/views/layouts/application.html.erb | |
@@ -6,6 +6,7 @@ | |
<%= csp_meta_tag %> | |
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> | |
+ <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> | |
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %> | |
</head> | |
diff --git a/config/environments/production.rb b/config/environments/production.rb | |
index a1c2337..8087ceb 100644 | |
--- a/config/environments/production.rb | |
+++ b/config/environments/production.rb | |
@@ -23,6 +23,7 @@ Rails.application.configure do | |
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? | |
# Compress CSS using a preprocessor. | |
+ config.assets.js_compressor = :uglifier | |
# config.assets.css_compressor = :sass | |
# Do not fallback to assets pipeline if a precompiled asset is missed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment