firstandthird / load-grunt-config

Grunt plugin that lets you break up your Gruntfile config by task
firstandthird.github.io/load-grunt-config/
MIT License
374 stars 64 forks source link

Grunt can't reference underscore/lodash and tasks break #126

Closed JeSuis closed 9 years ago

JeSuis commented 9 years ago

With normal grunt setup I had this at the top of my grunt file which gets used in settings for tasks. var _ = require('underscore');

After changing the setup as per instructions I get the error. >> ReferenceError: _ is not defined

And it breaks all the tasks. The var gets set but I haven't been able to successfully pass it in.

It's not really specific to underscore/lodash, would happen with setting any var for use in any task.

SolomoN-ua commented 9 years ago

Hi @JeSuis, you just need to add this line var _ = require('underscore'); in all task files, where you are using underscore. :)

JeSuis commented 9 years ago

ah I was hoping to not to have to do that to keep it dry, o well, thanks for your reply!

SolomoN-ua commented 9 years ago

unfortunately that's how javascript works :(

matt-bailey commented 8 years ago

Hi, I'm having a similar issue and wondered if you could give some example code? For example, take this standard Grunt task config (when not using load-grunt-config):

var compass = require('compass-importer');
grunt.initConfig({
    sass: {
        options: {
            importer: compass
        },
        ...        
    }
})

If I were using load-grunt-config with a sass.js task file, how/where would I put the var compass = require('compass-importer'); line?

SolomoN-ua commented 8 years ago

Hi @matt-bailey,

// sass.js file:
var compass = require('compass-importer');

module.exports = {
    options: {
        importer: compass
    },
    ...
};

I think something like this should work.

matt-bailey commented 8 years ago

Thanks for getting back to me @SolomoN-ua. I was hoping it would be that simple, but I'd already tried that and it didn't work.

When I ran the task in debug mode I could see that in the Options object importer=undefined. Let me know if you have any other thoughts.

SolomoN-ua commented 8 years ago

First of all check if compass-importer is installed and please provide your Gruntfile.js, sass.js files. It will be hard to investigate problem without this files.

cristinallamas commented 7 years ago

Hi, did you fix this issue? if so , could you share it? I found the same problem

var sass = require('node-sass');
var compass = require('compass-importer');
var assetFunctions = require('node-sass-asset-functions'); 

...

  sass:{
      options: {
        sourceMap: true,
        importer: compass,

...

Running "sass:dist" (sass) task
Verifying property sass.dist exists in config...OK
Files: sass/site.scss -> css/site.css
Options: precision=10, sourceMap, importer=undefined,