Reputation: 1140
Is it possible to generate dynamic filenames outside the built-in grunt tasks (e.g. concat
or min
)? I tried to use something like <config:concat.dist.dest>
or <%= dirs.dest %>
as it is described in the docs. But this never gets interpreted / compiled, it just writes out the string.
Update: That's what I tried based on jakub.g's answer. My grunt.js looks like this:
// ... grunt file contents
jquery: {
exclude: [],
version: '1.8.3',
dest: '../dist/js/jquery-' + grunt.task.directive('<config:jquery.version>') + '.js',
minify: false
}, // ... even more grunt file contents
grunt.task.directive('<config:jquery.version>')
returns null
. So the filename was named jquery-null.js
.
I then tried grunt.template.process('<%= grunt.jquery.version %>')
and grunt.config.process('<%= grunt.jquery.version %>')
, but none of them worked.
Upvotes: 1
Views: 1484
Reputation: 41248
This is hidden under the hood of Grunt magic in the built-in tasks and in fact not documented clear enough.
You need to use sth like grunt.task.directive(dest)
to evaluate things like <config:..>
. in a custom task.
For <%= foo %>
, have a look at Grunt templates.
Furthermore, wildcards like *
and **
and also not expanded by default, if you want to use them in custom tasks, you may use grunt.file.expandFiles()
.
Upvotes: 1