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

Compressing several files #26

Closed
evanworley opened this issue Mar 6, 2013 · 9 comments
Closed

Compressing several files #26

evanworley opened this issue Mar 6, 2013 · 9 comments

Comments

@evanworley
Copy link

How can this be used to recursively compress all files in a directory?

For example, I want to generate compressed versions of all my assets along side their uncompressed version.

Thanks,
Evan

@tkellen
Copy link
Member

tkellen commented Mar 6, 2013

This should be what you're looking for: http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically

@tkellen tkellen closed this as completed Mar 6, 2013
@evanworley
Copy link
Author

Hi Tkellen,

Thanks for the reply. I'm familiar with building the file object dynamically, but when I do it in the way that I am familiar with, I get an error that no archive is specified. In case I wasn't clear, I am looking to individually compresses all files in a given directory (so for each foo.txt there will be a foo.txt.gz next to it). This is pre-compression to use with nginx gzip_static feature.

Can you please help me understand what configuration will achieve this? Right now I have the following configuration and it does not work.

compress:
  dist:
    expand: true
    cwd: 'dist/'
    src: ['**/*.js', "**/*.css", "**/*.html"]
    dest: 'dist'
    ext: '.gz'

Thanks!
Evan

@tkellen tkellen reopened this Mar 6, 2013
@tkellen
Copy link
Member

tkellen commented Mar 7, 2013

Mode auto-detection is handled by the archive option, which doesn't apply to your style of compression.

Please try:

compress:
  dist:
    expand: true
    cwd: 'dist/'
    src: ['**/*.js', "**/*.css", "**/*.html"]
    dest: 'dist'
    ext: '.gz'
  options:
    mode: 'gzip'

@evanworley
Copy link
Author

I tried that configuration, and I got the following error message

Running "compress:dist" (compress) task
Warning: Unable to compress; no valid archive file was specified. Use --force to continue.

@tkellen
Copy link
Member

tkellen commented Mar 7, 2013

You're right. The gzip mode for this task is totally borked. I'll take a look at fixing it soon.

@evanworley
Copy link
Author

Thanks!

@shama shama closed this as completed in c1c21e5 Mar 13, 2013
@shama
Copy link
Member

shama commented Mar 13, 2013

@evanworley This should be fixed now on v0.4.2. Thanks!

@evanworley
Copy link
Author

Thanks for the quick fix. It works for the happy path case, but not when you have empty files. Please see my comment in c1c21e5

@shama
Copy link
Member

shama commented Mar 14, 2013

Fixed and published as v0.4.3. Thanks again!

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