- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix images precompilation for sprockets 4 #787
Fix images precompilation for sprockets 4 #787
Conversation
lib/administrate/engine.rb
Outdated
# regex no longer supported by assets.precompile | ||
# sprockets-rails 3 tracks down the calls to `font_path` and `image_path` | ||
# and automatically precompiles the referenced assets. | ||
unless Sprockets::Rails::VERSION.starts_with?('3') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
lib/administrate/engine.rb
Outdated
@@ -24,7 +24,13 @@ class Engine < ::Rails::Engine | |||
@@javascripts = [] | |||
@@stylesheets = [] | |||
|
|||
Engine.config.assets.precompile << /\.(?:svg)\z/ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra blank line detected.
0cfc562
to
396182b
Compare
lib/administrate/engine.rb
Outdated
@@ -24,7 +24,11 @@ class Engine < ::Rails::Engine | |||
@@javascripts = [] | |||
@@stylesheets = [] | |||
|
|||
Engine.config.assets.precompile << /\.(?:svg)\z/ | |||
if Sprockets::Rails::VERSION.start_with?("4") | |||
Dir["../../app/assets/images/**/*.svg"].each { |image| Engine.config.assets.precompile << image } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [103/80]
b1cea65
to
b977a19
Compare
lib/administrate/engine.rb
Outdated
@@ -24,7 +24,13 @@ class Engine < ::Rails::Engine | |||
@@javascripts = [] | |||
@@stylesheets = [] | |||
|
|||
Engine.config.assets.precompile << /\.(?:svg)\z/ | |||
if Sprockets::VERSION.start_with?("4") | |||
Dir[Engine.root.join('app/assets/images/**/*.svg')].each do |image| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
b977a19
to
c5aa4d4
Compare
@estepan I was going to make a PR for this myself, but it looks like you beat me to it! |
lib/administrate/engine.rb
Outdated
Engine.config.assets.precompile << /\.(?:svg)\z/ | ||
if Sprockets::VERSION.start_with?("4") | ||
Dir[Engine.root.join("app/assets/images/**/*.svg")].each do |image| | ||
Engine.config.assets.precompile << File.expand_path(image) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should have an assets initializer and whitelist the SVG assets, but this would work as well :)
lib/administrate/engine.rb
Outdated
Engine.config.assets.precompile << File.expand_path(image) | ||
end | ||
else | ||
Engine.config.assets.precompile << /\.(?:svg)\z/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your new method would work for Sprockets 3, what do you think about removing this line here entirely?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw you are right) I was in hurry writing this stuff) thanks)
@estepan what do you think of the implementation in https://github.com/thoughtbot/administrate/pull/648/files#diff-65032410b52e54dc1cfa4faaced808d3R27? |
…images-precompilation-sprockets4
lib/administrate/engine.rb
Outdated
Engine.config.assets.precompile << File.expand_path(image) | ||
end | ||
else | ||
Engine.config.assets.precompile += %w( administrate/manifest.js ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not use spaces inside percent literal delimiters.
lib/administrate/engine.rb
Outdated
@@ -24,7 +24,13 @@ class Engine < ::Rails::Engine | |||
@@javascripts = [] | |||
@@stylesheets = [] | |||
|
|||
Engine.config.assets.precompile << /\.(?:svg)\z/ | |||
if Sprockets::VERSION.start_with?('2') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
@BenMorganIO I've pulled latest master. But build fails for sprockets-4 appraisal
I spent half an hour on it but failed. https://github.com/thoughtbot/administrate/pull/648/files#diff-e927995a5a507ceba19f77e1416e130cR6 Any ideas? |
a6eb13b
to
db996e8
Compare
Just got #814 merged! Your PR does more than just fix the assets, it adds a manifest to the application. Also, I don't think we need to have an Appraisal just for Sprockets. I'd love to stay out of that complexity. If you'd like Administrate to use a manifest, could you open a simple PR just for that? |
No description provided.