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

Dynamic path expansion does not appear to be working. #14

Open
kitsunde opened this issue Jan 18, 2014 · 4 comments
Open

Dynamic path expansion does not appear to be working. #14

kitsunde opened this issue Jan 18, 2014 · 4 comments

Comments

@kitsunde
Copy link

Path expansion seem to pickup the name src and places the file in the running directory.

'zopfli': {
  'images': {
    files: {
      'src': ['build/img/cards/*'],
      'dest': 'build/img/cards/compressed',
      'expand': true,
      'ext': '.png'
    }
  }
},

Gives

Running "zopfli:images" (zopfli) task
File src created.
Original: 122158 bytes.
Compressed: 121931 bytes.
File src created.
Original: 108372 bytes.
Compressed: 108142 bytes.
File src created.
Original: 114956 bytes.
Compressed: 114729 bytes.
[...]

This still works as intended though:

'zopfli': {
  'images': {
    files: {
      'build/img/cards/compressed/479.png': 'build/img/cards/479.png'
    }
  }
},
@yumyo
Copy link

yumyo commented Jan 20, 2014

same here

@yumyo
Copy link

yumyo commented Jan 20, 2014

Appears to be a problem of sintax. This simple example is now working for me:

    zopfli: {
        options: {
            'iterations': 50,
        },
        files: {
            'expand': true,
            'cwd': 'assets/live/',
            'src': ['*.*'],
            'dest': 'assets/live/',
            'ext': '.gz'
        }
    },

@yumyo
Copy link

yumyo commented Jan 20, 2014

a step forward now (at least for me) is taking advantage of the rename funcrtion instead of the ext

so this:

rename  : function (dest, src) {
      var folder    = src.substring(0, src.lastIndexOf('/'));
      var filename  = src.substring(src.lastIndexOf('/'), src.length);
      return dest + folder + filename + '.gz';
    }

give me 31f01c2d.scripts-mob.min.js.gz from 31f01c2d.scripts-mob.min.js which is exactly what I need since I'm using grunt-wp-assets to version my assets but it could easily solve any similar need.

This closes #13

@radkodinev
Copy link

/ping @yumyo

You could just use the simpler 'ext': function (ext) { return ext + '.gz'; }.
More about it at gruntjs/grunt-contrib-compress#91 (comment).

Also there's also the extDot (see relevant Grunt docs) since Grunt 0.4.3 which may be useful too.

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

3 participants