Closed pbassut closed 8 years ago
Oh, and also, the same goes for the data
parameter. Would be great If I didn't need to replicate code. If param1
is defined on global data, the target data would 'inherit' those.
grunt itself doesn't allow you to do that thing where you want to share the files.
inside the task, each object block, except for the options
, is a target.
regarding your other suggestion, sounds like a good a idea to extend the local data
with the global data
, however grunt also overrides this behaviour by overriding defaults with specific local options
as you can see here https://github.com/gruntjs/grunt/blob/master/lib/grunt/task.js#L63
the only way i see to achieve this is to add a new option like localData
that could be extended by the global data
. however nothing prevents you to also use localData
option in the global and thus run into the same issue.
Also, remember this is just JS, so you could do that already by doing something like this:
...
var files = {
'myfile.html': ['src/myfile.html'],
'myfile2.html': ['src/myfile2.html'],
'myfile3.html': ['src/myfile3.html']
};
var data = {
param1: 'common thing'
};
var xtend = grunt.util._.extend;
...
processhtml: {
options: {
process: true,
},
dev: {
files: files,
options: {
data: xtend({param2: 'only for dev'}, data)
}
},
dist: {
files: files,
options: {
data: {
param1: xtend({param3: 'only for dist'}, data)
}
}
}
}
I know I could use plain js to accomplish this. But defining variable up top the gruntfile makes it look ugly IMO.
Thanks anyway.
So, I see myself replicating the same files to different targets. Usually, grunt plugins let you specify either a global parameter but also a task-specific one.
Question: is there a way to do that with grunt-processhtml?
To illustrate, instead of this:
I wish I could do this: