Reputation: 2321
I'm new to Sails.js and I'm having issues adding additional tasks to it's gruntfile. What I'm trying to do is use autoprefixer with Less, but everytime I call "sails lift" I get the following error:
error: Grunt :: Warning: Task "autoprefixer:multiple_files" not found. Use --force to continue.
>> Tasks directory "grunt-autoprefixer" not found.
Here's the lines I added to the gruntfile:
grunt.loadTasks('grunt-autoprefixer');
grunt.initConfig({
autoprefixer: {
options: {
browsers: ['last 2 version', 'ie 8', 'ie 7']
},
multiple_files: {
expand: true,
flatten: true,
src: 'assets/linker/styles/*.css',
dest: 'assets/linker/styles/'
},
concat: {
src: 'assets/linker/styles/*.css',
dest: 'assets/linker/styles/s.css'
}
},
//Rest of initConfig...
//compileAssets task
grunt.registerTask('compileAssets', [
'clean:dev',
'jst:dev',
'less:dev',
'autoprefixer:multiple_files',
'copy:dev',
'coffee:dev'
]);
I've tried removing "multiple_files" from the compileAssets task. I've tried installing autoprefixer both locally and globally but no dice, always the same error.
Any ideas?
Thanks!
Upvotes: 0
Views: 1980
Reputation: 11990
Use loadNpmTasks
and not loadTasks
.
loadNpmTasks
loads a locally installed module from node_modules
. This is what you need to use.
loadTasks
loads code from of a specified directory and doesn't do things like read package.json, recurse through module dependencies, and other good stuff that loadNpmTasks
handles.
This is why you are seeing the error: loadTasks
is looking for a directory called 'grunt-autoprefixer'.
If you like reading source, you can see what's going on in the code just before this line. :)
Also note: grunt modules need to be installed locally because of the way loadNpmTasks
works. This is by design. I got caught by this one when I first started using grunt because I assumed how the loading functionality worked. Whoops.
Upvotes: 3
Reputation: 10146
You're missing three letters.
grunt.loadTasks('grunt-autoprefixer');
should be:
grunt.loadNpmTasks('grunt-autoprefixer');
The former loads tasks from a directory that you specify, the latter loads the task from the directory in node_modules
.
Upvotes: 3