Open gleydsonst opened 2 years ago
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
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)
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