Skip to content
This repository has been archived by the owner on Feb 18, 2021. It is now read-only.

Dynamic mapping / rasterization bug #16

Open
ismay opened this issue Jun 25, 2014 · 5 comments
Open

Dynamic mapping / rasterization bug #16

ismay opened this issue Jun 25, 2014 · 5 comments

Comments

@ismay
Copy link

ismay commented Jun 25, 2014

I'm using svg2png to render fallback png's and am encountering several bugs: when I run grunt svg2png with this config:

  build: {
    files: [{
      cwd: 'src/assets/ico',
      src: ['*.svg'],
      dest: 'build',
      ext: '.png'
    }]
  }

it hangs at 0% when rasterizing.

Adding expand

When I add expand:true the rasterization works, but folder structure it outputs is wrong. With src/assets/ico/test.svg the result is build/test.png/src/assets/ico/test.png. So it outputs the filename as a folder first and then messes up the folder structure (I believe it should be build/assets/ico/test.png). When I fiddle around with the cwd and src it keeps outputting the filename as a folder.

Removing ext

When I remove ext:'png' the folder structure becomes: build/test.svg/src/assets/ico/test.png.

Summary

  1. Doesn't work without expand:true
  2. Weird dynamic mapping behaviour

Any idea what's going wrong? To me it seems like there's something wrong with svg2png's implementation of grunt's dynamic mapping syntax, since similar syntax seems to work just fine with other plugins (copy for example).

@ismay ismay changed the title Stays at 0% when rasterizing Dynamic mapping doesn't work Jun 25, 2014
@ismay ismay changed the title Dynamic mapping doesn't work Dynamic mapping / rasterization bug Jun 25, 2014
@ismay ismay changed the title Dynamic mapping / rasterization bug Dynamic mapping / rasterization bugs Jun 25, 2014
@ismay
Copy link
Author

ismay commented Jun 25, 2014

After some fiddling, the only syntax that seems to work for me is:

  build: {
    files: [{
      cwd: 'src/',
      src: ['assets/ico/**/*.svg'],
      dest: 'build/',
      expand: false
    }]
  }

So I still don't know what exactly was going wrong, but hope this is of help!

@ismay ismay changed the title Dynamic mapping / rasterization bugs Dynamic mapping / rasterization bug Jun 26, 2014
@dbushell
Copy link
Owner

dbushell commented Jul 7, 2014

Thanks @ismay, I'm glad you got it working :)

Recent changes had broke the old config options and I'm a bit behind on my Grunt files knowledge to understand exactly how it should work. I believe it's now correct though!

@ismay
Copy link
Author

ismay commented Jul 7, 2014

I'm glad you got it working :)

Me too :)! I think I made a couple of mistakes in the config at first, but the final config should have worked with expand:true instead of expand:false (if I'm not misinterpreting Grunt's documentation: http://gruntjs.com/configuring-tasks#files).

I believe it's now correct though!

Is it this commit that should have fixed the dynamic mapping: 7297635? Because I can take a look and see if everything's working as expected now, if you'd like.

@msguerra74
Copy link

Something happened between the last version and this one. I had been using the following config, which worked just fine:

svg2png: {
  svg: {
    files: [{
      src: '<%= source %>/_assets/images/**/*.svg',
      dest: '<%= source %>/assets/img'
    }]
  }
},

but now, I've had to modify it to this to make it work:

svg2png: {
  svg: {
    files: [{
      expand: false,
      cwd: '<%= source %>/_assets/images/',
      src: ['**/*.svg'],
      dest: '<%= source %>/assets/img'
    }]
  }
},

I am happy that I can still make it work, but it doesn't seem to follow the same structure as some of my other grunt tasks, and since it worked fine previously, something doesn't feel right here. Are there any plans to look into this, or do I change the config to what's working and move on? Thanks!

@coreyworrell
Copy link

This doesn't seem to work anymore. If I do try this, the rasterization process just hangs up at 0, and nothing happens.

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

No branches or pull requests

4 participants