Skip to content

Commit

Permalink
Switch to digested assets using either propshaft or sprockets (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
westonganger authored Dec 3, 2024
1 parent c2e030b commit 92adff2
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 31 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# CHANGELOG

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

### v1.0.2 - November 7, 2024 - [View Diff](https://github.com/westonganger/rails_i18n_manager/compare/v1.0.1...v1.0.2)
- [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`.
Expand Down
18 changes: 10 additions & 8 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ def get_env(name)
(ENV[name] && !ENV[name].empty?) ? ENV[name] : nil
end

gem "rails", get_env("RAILS_VERSION")
rails_version = get_env("RAILS_VERSION")

db_gem = get_env("DB_GEM") || "sqlite3"
gem db_gem, get_env("DB_GEM_VERSION")
gem "rails", rails_version

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

db_gem = get_env("DB_GEM") || "sqlite3"
gem db_gem, get_env("DB_GEM_VERSION")

group :development do
gem "webrick"
gem "better_errors"
gem 'binding_of_caller'
gem "puma"
end
3 changes: 3 additions & 0 deletions app/assets/config/rails_i18n_manager_manifest.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//= link_tree ../images/rails_i18n_manager
//= link_directory ../stylesheets/rails_i18n_manager .css
//= link_directory ../javascripts/rails_i18n_manager .js
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion app/models/rails_i18n_manager/application_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class ApplicationRecord < ActiveRecord::Base

include ActiveSortOrder

scope :multi_search, ->(full_str){
scope :multi_search, ->(full_str){
if full_str.present?
rel = self

Expand Down
42 changes: 21 additions & 21 deletions lib/rails_i18n_manager/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,27 @@ class Engine < ::Rails::Engine
app.middleware.use ::ActionDispatch::Static, "#{root}/public"
end

### Were not using sprockets were just storing everything in public
### Sprockets Config below
# initializer "rails_i18n_manager.assets.precompile" do |app|
# app.config.assets.precompile << "rails_i18n_manager_manifest.js" ### manifest file required
# app.config.assets.precompile << "rails_i18n_manager/favicon.ico"

# ### Automatically precompile assets in specified folders
# ["app/assets/images/"].each do |folder|
# dir = app.root.join(folder)

# if Dir.exist?(dir)
# Dir.glob(File.join(dir, "**/*")).each do |f|
# asset_name = f.to_s
# .split(folder).last # Remove fullpath
# .sub(/^\/*/, '') ### Remove leading '/'

# app.config.assets.precompile << asset_name
# end
# end
# end
# end
initializer "rails_i18n_manager.assets.precompile" do |app|
# this initializer is only called when sprockets is in use

app.config.assets.precompile << "rails_i18n_manager_manifest.js" ### manifest file required
app.config.assets.precompile << "rails_i18n_manager/favicon.ico"

### Automatically precompile assets in specified folders
["app/assets/images/"].each do |folder|
dir = app.root.join(folder)

if Dir.exist?(dir)
Dir.glob(File.join(dir, "**/*")).each do |f|
asset_name = f.to_s
.split(folder).last # Remove fullpath
.sub(/^\/*/, '') ### Remove leading '/'

app.config.assets.precompile << asset_name
end
end
end
end

end
end

0 comments on commit 92adff2

Please sign in to comment.