Skip to content
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

What happened to relativeTo? #196

Open
sebastian-zarzycki opened this issue Mar 21, 2015 · 5 comments
Open

What happened to relativeTo? #196

sebastian-zarzycki opened this issue Mar 21, 2015 · 5 comments

Comments

@sebastian-zarzycki
Copy link

0.12.x versions broke cssmin for me completely. The result is just empty file, because relativeTo is not passed to clear-css (this results in an empty file). Additionally, something's wrong with url rewriting. In 0.11.0, I had just to to pass root to options (and relativeTo was set per file in task itself). Now, relativeTo is gone, there's no way to pass it for every file from grunt config, but even if I fake it and set from config, url rewriting doesn't work.

Simple case:

  • css file sitting in ./client/style/application/image.css
  • in it, as part of class def : background-image: url('../../resource/asset/logos/white/logo.png');
  • target dir, dist, has ./dist/resource/(...) in it
  • grunt:
cssmin: {
    options: {
        keepSpecialComments: 0,
        root: 'client'
    }
    custom: {
        files: [
            {
                src: ['client/style/application/image.css'],
                dest: 'dist/image.css'
            }
        ]
    }
}

dist/image.css

expected result
background-image: url('resource/asset/logos/white/logo.png');

actual result
background-image: url('../../resource/asset/logos/white/logo.png');

same config in 0.11.0
background-image: url(/resource/asset/logos/white/logo.png);
(almost correct, but adding the leading / at the beginning - why?)

@nklein1
Copy link

nklein1 commented Apr 14, 2015

I'm also experiencing a similar issue. Using the following code...

cssmin: {
   options: {
      rebase: true,
      relativeTo: '<%= compile_dir %>',
      target: '<%= compile_dir %>',
      keepSpecialComments: 0, 
      advanced: true
   },
   bin: {
      files: [{
         src: [
            '<%= vendor_files.css %>',
            '<%= compile_dir %>/assets/<%= pkg.name %>-<%= pkg.version %>.css'
         ],
         dest: '<%= compile_dir %>/assets/<%= pkg.name %>-<%= pkg.version %>.css'
      }]
   }
},

...produces different results in different versions of cssmin:

Result in v0.11.0 (rebasing produces correctly-formatted path)

.k-map .k-marker{background-image:url(../vendor/kendo-ui/styles/Default/markers.png)}

Result in v0.12.2 (rebasing produces malformed path, resulting in 404 error)

.k-map .k-marker{background-image:url(../../vendor/kendo-ui/styles/Default/markers.png)}

@THemming
Copy link

We're seeing this in production too. Having to stick on v0.11 as later versions produce incorrect url paths.

@Bnaya
Copy link

Bnaya commented Oct 14, 2015

We are having the same issue

@Bnaya
Copy link

Bnaya commented Oct 14, 2015

#241

@pauloya
Copy link

pauloya commented Jul 6, 2016

I spent some time trying to get rebase working with cssmin for the latest version 1.0.1 and couldn't, until I saw this thread and tried it with version 0.11.0. I finally managed to get it working as I needed with the following options:

 cssmin: {
            options: {
                keepBreaks: true,
                rebase: true,
                target: "../Web/common",
                showLog: true,
                keepSpecialComments: true,
                aggressiveMerging: false,
                mediaMerging: false,
                restructuring: false
            }
        }

So it seems to me there is a problem not only an issue with relativeTobut also with target? Since I didn't need to use relativeToto do what I needed, but I needed to use an older version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants