Last active
April 18, 2023 00:35
-
-
Save westonganger/c0c082b2f9a202772dae75938a0f7377 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# lib/<project_name>/engine.rb | |
module RailsI18nManager | |
class Engine < ::Rails::Engine | |
isolate_namespace RailsI18nManager | |
initializer "rails_i18n_manager.load_static_assets" do |app| | |
### Expose static assets | |
app.middleware.use ::ActionDispatch::Static, "#{root}/public" | |
end | |
### 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment