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

Support 'Rename' Option #79

Closed
elsbree opened this issue Jan 17, 2014 · 9 comments
Closed

Support 'Rename' Option #79

elsbree opened this issue Jan 17, 2014 · 9 comments

Comments

@elsbree
Copy link

elsbree commented Jan 17, 2014

I'm attempting to configure a task that compresses all the files in a directory, and leaves their file extensions intact.

I've defined my compress config as follows:

compress: {
    options: {
        mode: 'gzip',
        pretty: true
    },
    dev: {
        expand: true,
        cwd: 'public/',
        src: '**/*',
        dest: 'dist/dev',
        rename: function(dest, src) {
            var out = dest + '/' + src;
            out = out.replace('.gz', '');

            grunt.log.writeln(out);

            return out;
        }
    },
},

But when I run compress:dev, I see the following log output:
(just a short snippet as an example)

dist/dev/stylesheets/var/template/themes/shifty.css
dist/dev/stylesheets/var/template/themes/squary.css
dist/dev/stylesheets/var/template/themes/stacky-fat.css
dist/dev/stylesheets/var/template/themes/stacky-tall.css
Created dist/dev/stylesheets/var/template/themes/shifty.css.gz (2.9 kB)
Created dist/dev/stylesheets/var/template/themes/squary.css.gz (2.4 kB)
Created dist/dev/stylesheets/var/template/themes/stacky-fat.css.gz (3.1 kB)
Created dist/dev/stylesheets/var/template/themes/stacky-tall.css.gz (2.9 kB)

The correct values are being returned from the rename function, but the output files' names are not changed. Is the rename function not supported in grunt-contrib-compress, or am I missing something?

netpro2k added a commit to netpro2k/grunt-contrib-compress that referenced this issue Mar 13, 2014
existing extension without issue (see
gruntjs#79) if the user
wishes to add an extension they can do so via ext or rename.
@netpro2k
Copy link
Contributor

The issue is not that rename isnt supported, but rather that the task automatically applies a default extension reguardless of if you have a rename function or not. I tried specifying a blank "ext" but that gives no extension, and specifiying the original extension (say ".js") causes issues with files with multiple dots in the name (#67)

I created a commit for my own use that simply removes automatic extension adding, but I doubt it would be accepted as a PR: netpro2k@7c7e695

@tkellen
Copy link
Member

tkellen commented Mar 14, 2014

@netpro2k I agree that the extension should be handled by ext or rename. Please submit that PR.

@tkellen
Copy link
Member

tkellen commented Mar 14, 2014

@tkellen
Copy link
Member

tkellen commented Mar 14, 2014

@ctalkington Is there any reason this code can't go?
netpro2k@7c7e695

@ctalkington
Copy link
Member

hum, dont think that is code that I did but im all for using grunt features where possible.

@btilford
Copy link

This extension is essentially useless for gziping css/js whithout this fixed. Extremely common things like version numbers or .min.js completely break the plugin.

@trullock
Copy link

+1 for not renaming by default

tkellen pushed a commit that referenced this issue Jul 14, 2014
existing extension without issue (see
#79) if the user
wishes to add an extension they can do so via ext or rename.

Closes GH-91
@ctalkington
Copy link
Member

@vladikoff think this has been merged?

@vladikoff
Copy link
Member

Yeap!

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

7 participants