Skip to content

Commit 92adff2

Browse files
authored
Switch to digested assets using either propshaft or sprockets (#21)
1 parent c2e030b commit 92adff2

File tree

9 files changed

+36
-31
lines changed

9 files changed

+36
-31
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# CHANGELOG
22

33
### Unreleased - [View Diff](https://github.com/westonganger/rails_i18n_manager/compare/v1.0.2...master)
4-
- Nothing yet
4+
- [#21](https://github.com/westonganger/rails_i18n_manager/pull/21) - Switch to digested assets using either propshaft or sprockets
55

66
### v1.0.2 - November 7, 2024 - [View Diff](https://github.com/westonganger/rails_i18n_manager/compare/v1.0.1...v1.0.2)
77
- [View commit](https://github.com/westonganger/rails_i18n_manager/commit/ccdeea7cdfb409b61e5d8ef23b03c52fbfd027c0) - Allow `.yaml` files to be uploaded. Previously the upload validation would only allow `.yml`.

Gemfile

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,19 @@ def get_env(name)
1515
(ENV[name] && !ENV[name].empty?) ? ENV[name] : nil
1616
end
1717

18-
gem "rails", get_env("RAILS_VERSION")
18+
rails_version = get_env("RAILS_VERSION")
1919

20-
db_gem = get_env("DB_GEM") || "sqlite3"
21-
gem db_gem, get_env("DB_GEM_VERSION")
20+
gem "rails", rails_version
2221

23-
group :development, :test do
24-
gem "sprockets-rails" ### just for dummy app
22+
if rails_version.nil? || rails_version.sub("~>","").to_f >= 8.0
23+
gem "propshaft"
24+
else
25+
gem "sprockets-rails", require: "sprockets/railtie"
2526
end
2627

28+
db_gem = get_env("DB_GEM") || "sqlite3"
29+
gem db_gem, get_env("DB_GEM_VERSION")
30+
2731
group :development do
28-
gem "webrick"
29-
gem "better_errors"
30-
gem 'binding_of_caller'
32+
gem "puma"
3133
end
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//= link_tree ../images/rails_i18n_manager
2+
//= link_directory ../stylesheets/rails_i18n_manager .css
3+
//= link_directory ../javascripts/rails_i18n_manager .js

app/models/rails_i18n_manager/application_record.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class ApplicationRecord < ActiveRecord::Base
44

55
include ActiveSortOrder
66

7-
scope :multi_search, ->(full_str){
7+
scope :multi_search, ->(full_str){
88
if full_str.present?
99
rel = self
1010

lib/rails_i18n_manager/engine.rb

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,27 @@ class Engine < ::Rails::Engine
1717
app.middleware.use ::ActionDispatch::Static, "#{root}/public"
1818
end
1919

20-
### Were not using sprockets were just storing everything in public
21-
### Sprockets Config below
22-
# initializer "rails_i18n_manager.assets.precompile" do |app|
23-
# app.config.assets.precompile << "rails_i18n_manager_manifest.js" ### manifest file required
24-
# app.config.assets.precompile << "rails_i18n_manager/favicon.ico"
25-
26-
# ### Automatically precompile assets in specified folders
27-
# ["app/assets/images/"].each do |folder|
28-
# dir = app.root.join(folder)
29-
30-
# if Dir.exist?(dir)
31-
# Dir.glob(File.join(dir, "**/*")).each do |f|
32-
# asset_name = f.to_s
33-
# .split(folder).last # Remove fullpath
34-
# .sub(/^\/*/, '') ### Remove leading '/'
35-
36-
# app.config.assets.precompile << asset_name
37-
# end
38-
# end
39-
# end
40-
# end
20+
initializer "rails_i18n_manager.assets.precompile" do |app|
21+
# this initializer is only called when sprockets is in use
22+
23+
app.config.assets.precompile << "rails_i18n_manager_manifest.js" ### manifest file required
24+
app.config.assets.precompile << "rails_i18n_manager/favicon.ico"
25+
26+
### Automatically precompile assets in specified folders
27+
["app/assets/images/"].each do |folder|
28+
dir = app.root.join(folder)
29+
30+
if Dir.exist?(dir)
31+
Dir.glob(File.join(dir, "**/*")).each do |f|
32+
asset_name = f.to_s
33+
.split(folder).last # Remove fullpath
34+
.sub(/^\/*/, '') ### Remove leading '/'
35+
36+
app.config.assets.precompile << asset_name
37+
end
38+
end
39+
end
40+
end
4141

4242
end
4343
end

0 commit comments

Comments
 (0)