rails / sass-rails

Ruby on Rails stylesheet engine for Sass
MIT License
860 stars 333 forks source link

Different precompiled files with same code #321

Closed agrass closed 5 years ago

agrass commented 9 years ago

When I precompile the same css in two servers I get differents css minimized. I don't know the reason of this issue,I have the same config (config.assets.css_compressor = :sass)

For example one part of the unpacked minimized css in server 1 is like this (the same that the real file) :


.c3-tooltip
{
    border-collapse:collapse;
    border-spacing:0;
    background-color:#fff;
    empty-cells:show;
    -webkit-box-shadow:7px 7px 12px -9px #777;
    -moz-box-shadow:7px 7px 12px -9px #777;
    box-shadow:7px 7px 12px -9px #777; 
    opacity:0.9
}
Then in server 2 I get this (webkit-box-shadow and -moz-box-shadow were removed):

.c3-tooltip
{
    border-collapse:collapse;
    border-spacing:0;
    background-color:#fff;
    empty-cells:show;
    box-shadow:7px 7px 12px -9px #777;
    opacity:0.9
}
arthurnn commented 9 years ago

how are you getting that info? Are you doing curl calls to 2 different servers and seeing different results? Not sure how to simulate this issue, if you could provide a sample app would help out. thanks

agrass commented 9 years ago

Yes something like that, I have a loadbalancer with different servers and sometimes the stylesheets were not loaded. I checked the names of the css compressed files and in one server have a different fingerprint. Next uncompressing the files with (http://cssunpacker.com/) I realize that one of the servers when compress the css is removing some -webkit, -moz and other syntaxis.

Server 1 and 2 have the same code, the only difference is that one is in a normal EC2 machine with rbenv and the other one is in a stack of OpsWorks without rbenv, both have the same Gemfile.lock

rafaelfranca commented 9 years ago

one server I have a different fingerprint

This means that the file content is not the same. Something is generating different files in your server.

If the code is the same and the version of the gems are the same I don't see why sprockets would generate different results. Make sure that your assets folders and dependencies are the same.

agrass commented 9 years ago

Yes, the compressed file in one server remove some lines as shown in the first comment. I just realize that most of the files that have this problem have ".css.scss" extension and files with .sass extension don't have this problem. Could be something related with this? I know that in the latest version of sass-rails the .css.scss extension is deprecated, Its possible that the extenssion cause this issue?

rafaelfranca commented 9 years ago

Don't think so. Given the same environment and the same code, I don't see how the files would be different. I'd make sure that the environment is the same in both servers first (gem versions, dependencies versions, assets code)

agrass commented 9 years ago

It's the same code and gem versions. The deploy in both servers use the same branch. In the server with the problem if I check the non precompiled assets It's exactly the same of the other server, but when I compress it, some attributes as shown in the first comment were removed.

rafaelfranca commented 9 years ago

Does that code being generated by some gem like compass or bourbon? Seems only the prefix styles are missing, but the box-shadow is there.

agrass commented 9 years ago

No, the only difference are that in the server of the problem I'm using AWS opsworks with some chef recipes and I don't have rbenv configured, It's possible that some of this is cousing this issue? (I use the default recipes of opsworks rails layer). The box-shadow is there in both servers, the compression remove the whole line "-webkit-box-shadow" and "-moz-box-shadow".Thanks, I would really appreciate any help or comments about this issue.

rafaelfranca commented 9 years ago

"-webkit-box-shadow" and "-moz-box-shadow"

In our sass code are these properties generated by some kind of mixin?

Like:

@include box-shadow(7px 7px 12px -9px #777);

Not having rbenv configured can be a reason for this yeah, if that means that global gems installed on the machine are affecting your application, but I'd guess bundler would protect you.

agrass commented 9 years ago

not, It's not generated by some kind of mixin, they are in some imports of scss from the application.sass with normal css syntax.

rafaelfranca commented 9 years ago

:confounded: so this is now even more weird. If it is just normal css syntax I can't see how this same file can be different in different servers.

agrass commented 9 years ago

yes is very weird. Finally I give up with this issue and decided to use the gem 'asset_sync' to upload the assets on s3.

Fudoshiki commented 9 years ago

RAILS_ENV=production rake assets:precompile on server dropped

  font-family: "ヒラギノ丸ゴ ProN W4", "Hiragino Maru Gothic Pro", "メイリオ", Meiryo, Helvetica, sans-serif
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0)
  -ms-text-size-adjust: 100%
  -webkit-text-size-adjust: 100%

from html section

on local machine not

ekaitzht commented 9 years ago

The same is happening to me my css vendor prefixes are removing in production enviroment but not in my local machine. Here you can get more info http://stackoverflow.com/questions/32179803/rails-removing-css-vendor-prefixes-in-production-enviroment