You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have similar issue. RAILS_ENV=production bundle exec rake assets:precompile always crash, there is no problem with development environment. After isolate scss file one by one, I realized that it crashed due to "asset-url" inside scss file.
@font-face {
font-family: 'Source Sans Pro';
src: asset-url('source-sans-pro-v14-latin-regular.eot'); --> this line causes crash
...
font-weight: normal;
font-style: normal;
}
I tried many ways that found by google such as
Downgrade sprockets from "4.0" to "3.7.2"
Add "env.export_concurrent = false" to initializers/assets.rb
Play around with Rails.application.config.assets.precompile += ....
...
None of them work. Finally, I could fix it by below hack. I manually handle get method to asset files (depending on file name, then I redirect to corresponding asset file)
Change from "asset-url()" to "url()"
Update config/routes.rb by adding below code
if Rails.env.production?
f_redirector = lambda { |params, _req|
_path = params[:name] + _req.path.gsub(/.*\./, '.')
ApplicationController.helpers.asset_path(_path)
}
constraint = ->(request) {
request.path.ends_with?('.eot') ||
request.path.ends_with?('.woff') ||
request.path.ends_with?('.ttf') ||
request.path.ends_with?('.svg') ||
request.path.ends_with?('.png')
}
get '/assets/*name', to: redirect(f_redirector), constraints: constraint
end
This is a dirty hack, but at least my production could work temporary work for now.
I'm using the new cssbundling-rails gem. It's working perfect in dev, but in prod i'm getting this error when i'm trying to compile the assets:
following the doc: https://guides.rubyonrails.org/asset_pipeline.html#css-and-sass
just
url("ruby.png")
doesn't work, but it worked with the webpacker:RAILS_ENV=production bundle exec rake assets:precompile
The text was updated successfully, but these errors were encountered: