Skip to content
This repository has been archived by the owner on Mar 26, 2018. It is now read-only.

Allow to prepend hashes #53

Closed
mgol opened this issue Sep 22, 2014 · 7 comments
Closed

Allow to prepend hashes #53

mgol opened this issue Sep 22, 2014 · 7 comments

Comments

@mgol
Copy link

mgol commented Sep 22, 2014

I prefer the format used by grunt-rev which prepended hashes instead of appending them. It's easier to handle as in other tasks Grunt configuration I can catch both files via prepending {*,} to the pattern. grunt-filerev appends the hash before the extension so I actually need to know extensions of matched files to be able to match them both.

Could you add a configuration option to prepend instead of appending? Am I missing something?

@eddiemonge
Copy link
Member

Does filename-* not work here?

@mgol
Copy link
Author

mgol commented Oct 6, 2014

Do you mean filename.*? I don't know what you mean; the use case is that I have a pattern for file names in a variable pattern and I need to transform it. Now I just use '{*.,}' + pattern, how would I achieve the same effect when hashes are appended?

@eddiemonge
Copy link
Member

Im not sure what you mean exactly. Could you give a more info on the pattern?

@mgol
Copy link
Author

mgol commented Oct 6, 2014

OK, it's not a pattern but a variable.

I have a task that grabs an HTML file and finds blocks enclosed in comments:

<!-- useMinAndConcat someFile.js -->

and

<!-- endUseMinAndConcat -->

then preprocesses script tags inside the block in the preparation task. Next, other tasks generate a bundle file (concatenated, minified etc.) and put the resulting bundle in someFile.js. Then the final stage of useMinAndConcat is performed that replaces the contents between its control comments with a single script tag to the resulting bundle. It already knows the file name but it's passed through grunt-rev so instead of writing:

<script src="/someFile.js"></script>

the path written to src is grunt.file.expand('{*.,}' + destFile) where destFile is someFile.js - it's taken from the template.

Now, to do the same with grunt-filerev I'd have to do grunt.file.expand(destFile.replace(/\.js$/, '') + '{,.*}.js' ) which is unecessarily verbose and assumes I know the extension (which might not be true in other cases). I can extract the extension by myself but it's really adding way too much code than it used to; simply prepending the hash would solve all this problems to me.

@eddiemonge
Copy link
Member

You can't map the output of grunt.filerev.summary to get what you need so you dont need the pattern?

@mgol
Copy link
Author

mgol commented Oct 7, 2014

Hmm, I guess I can try that. I'll check if all my use cases can be covered by that.

@mgol
Copy link
Author

mgol commented Nov 14, 2014

It seems all my use cases can be solved using grunt.filerev.summary; I'm closing the ticket then.

@mgol mgol closed this as completed Nov 14, 2014
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

2 participants