Closed benfrain closed 10 years ago
Looking around there doesn't seem to be any precedent for actually prefixing grunt module names the way I did... Hmmm.
The "grunt-contrib" namespace is reserved for tasks maintained by the Grunt team, please name your task something appropriate that avoids that naming scheme.
That's basically the only guideline the Grunt docs give.
I'll see if renaming the module breaks anything in a catastrophic way... ;)
would be a great feature - I'm using load-grunt-tasks extensively and this is only one plugin so far, that I need to put directly into my Gruntfile
I renamed the repo and npm module just now. dr-grunt-svg-sprites
is now deprecated.
Worst case effects of this - I hope - will be the module not updating in node_modules. I'm crossing my fingers this won't break anything ;)
Hi All. Sorry, was this ever resolved?
I'm using load-grunt-config with jit-grunt and it's not picking up the plugin. There's an option to pass a static mapping to jit-grunt, but I can't seem to get that to work either.
I've tried multiple variations of the following kind of config:
require('load-grunt-config')(grunt, {
jitGrunt: {
staticMappings: {
svgsprites: 'grunt-dr-svg-sprites'
}
},
// ...
I then have a separate file called `svgsprites.js' which contains the actual task config. All my other tasks work fine, but this is the only one jit-grunt doesn't seem to recognise.
Can anyone share their config if they got it working?
Try using "svg-sprites"
instead of svgsprites
and see if that helps:
grunt.initConfig({
"svg-sprites": {
options: {
// Task-specific options go here.
},
},
});
I tried a few variations around that theme, but none worked. For example:
require('load-grunt-config')(grunt, {
jitGrunt: {
staticMappings: {
svg-sprites: 'grunt-dr-svg-sprites'
}
},
The above throws a syntax error - it doesn't like the '-' in the word 'svg-sprites'.
Then wrapping svg-sprites in quotes, like this:
require('load-grunt-config')(grunt, {
jitGrunt: {
staticMappings: {
"svg-sprites": "grunt-dr-svg-sprites"
}
},
Throws the following error:
Warning:
jit-grunt: Plugin for the "svg-sprites" task not found.
If you have installed the plugin already, please setting the static mapping.
See https://github.com/shootaroo/jit-grunt#static-mappings
Warning: Task "svg-sprites" not found. Use --force to continue.
Referring to the jit-grunt
documentation on static mapping doesn't really help much unfortunately.
Oh damn... It seems like jit-grunt
is much stricter than load-grunt-tasks
(which just works OOTB) :(
I just added a more strictly named task in 0.9.15 of the plugin. Update grunt-dr-svg-sprites
and use "dr-svg-sprites"
instead of "svg-sprites"
and jit-grunt
should play nice :)
That's awesome thank you, it seems to be fixed now.
For anyone else who is also using load-grunt-config
and jit-grunt
here's my set up.
In Gruntfile.js
set your static mapping like so:
require('load-grunt-config')(grunt, {
jitGrunt: {
staticMappings: {
"dr-svg-sprites": 'grunt-dr-svg-sprites'
}
},
// The rest of your config...
Then create a config file for the task called grunt/dr-svg-sprites.js
. This is a good tutorial on using grunt-dr-svg-sprites
, where you can find out a bit more about what to put in the config.
I'd forgotten that I'm also using a task called grunt-concurrent
, so I needed to make sure my task name alias matched dr-svg-sprites
.
I don't think you need staticMappings
anymore (jitGrunt: true
should be enough) after the version update(?) - all you need is the grunt/dr-svg-sprites.js
and all references to the task be dr-svg-sprites
.
I just tried it out with your tricked out setup: load-grunt-config
, grunt-concurrent
, jit-grunt
and then grunt-dr-svg-sprites
. Worked like a charm :)
Be sure grunt-dr-svg-sprites
is actually updated to version 0.9.15
Sweet! I'll try it out. Thanks again.
At present the task won't be auto-loaded by handy utilities like https://github.com/sindresorhus/load-grunt-tasks
I think this is because that task pattern matches against
grunt-*
as its globbing pattern.Perhaps it would therefore be useful to rename:
grunt.loadNpmTasks('dr-grunt-svg-sprites');
To:
grunt.loadNpmTasks('grunt-dr-svg-sprites');
Just a thought! :)