Giter VIP home page Giter VIP logo

load-grunt-config's Introduction

load-grunt-config Build Status

load-grunt-config is a Grunt library that allows you to break up your Gruntfile config by task. For most small projects a single Gruntfile.js is perfect. But as a project grows, the Gruntfile.js can quickly become unmanagable; this is where load-grunt-config comes in handy. It was heavily inspired by Thomas Boyt's "More Maintainable Gruntfiles".

Features

Installation

npm install -D load-grunt-config

Example

Basic Gruntfile.js

module.exports = function(grunt) {

	require('load-grunt-config')(grunt);

};

Gruntfile.js with options

module.exports = function(grunt) {
	var path = require('path');

	require('load-grunt-config')(grunt, {
		// path to task.js files, defaults to grunt dir
		configPath: path.join(process.cwd(), 'grunt'),
		
		// path to project package.json file
		packageJsonPath: path.join(process.cwd(), 'package.json'),

		// auto grunt.initConfig
		init: true,

		// data passed into config.  Can use with <%= test %>
		data: {
			test: false
		},

		// use different function to merge config files
		mergeFunction: require('recursive-merge'),

		// can optionally pass options to load-grunt-tasks.
		// If you set to false, it will disable auto loading tasks.
		loadGruntTasks: {
		
			pattern: 'grunt-*',
			config: require('./package.json'),
			scope: 'devDependencies'
		},

		//can post process config object before it gets passed to grunt
		postProcess: function(config) {},

		//allows to manipulate the config object before it gets merged with the data object
		preMerge: function(config, data) {}
	});

};

Optionally you can use jit-grunt instead of load-grunt-tasks

module.exports = function(grunt) {

	require('load-grunt-config')(grunt, {
		// ...
		jitGrunt: {
		    // here you can pass options to jit-grunt (or just jitGrunt: true)
		    staticMappings: {
		        // here you can specify static mappings, for example:
		        sprite: 'grunt-spritesmith',
                hello: 'custom/say-hello.js'
		    }
		}
	});

};

Note: if you have problems with auto loading of some tasks please check jit-grunt#static-mappings

Grunt tasks files

Here's what the files in your grunt/ folder could look like. You can use either .js, .json, .yaml, or .cson - whatever you prefer and you can mix and match as you see fit.

Example js file returning an object - grunt/watch.js

module.exports = {
  all: {
    files: [
      '<%= jshint.all %>',
      'grunt/*.yaml'
    ],
    tasks: [
      'default'
    ]
  }
};

Example js file returning a function - grunt/jshint.js

module.exports = function (grunt, options) {
  return {
    all: [
      'Gruntfile.js',
      'grunt/*.js',
      'lib/*.js',
      'test/*.js',
      options.someFile
    ]
  };
};

Example json file - grunt/clean.json

{
  "all": [
    "<%= project.dest %>",
    "target/*.js"
  ]
}

Example yaml file - grunt/notify.yaml

default:
  options:
    message: 'Default finished'

Aliases

If your grunt/ folder contains an aliases.(js|.json|yaml|cson) file, load-grunt-config will use that to define your tasks aliases (like grunt.registerTask('default', ['jshint']);).

The following examples show the same aliasses definition written in various formats

Example yaml file - grunt/aliases.yaml

default: []

lint:
  description: 'Helps to make our code better'
  tasks:
    - 'jshint'
    - 'csslint'

build:
  - 'lint'
  - 'mocha'
  - 'notify'

Example json file - grunt/aliases.json

{
  "default": [],
  "lint": [
    "jshint",
    "csslint"
  ],
  "build": [
    "lint",
    "mocha",
    "notify"
  ]
}

Example JavaScript file returning an object - grunt/aliases.js

module.exports = {
  'default': [],
  'lint': [
    'jshint',
    'csslint'
  ],
  'build': [
    'lint',
    'mocha',
    'notify'
  ]
};

Example JavaScript file returning a function grunt/aliases.js Useful if there is need to compute something before return.

module.exports = function (grunt, options) {
  // computation...
  return {
    'default': [],
    'lint': [
      'jshint',
      'csslint'
    ],
    'build': [
      'lint',
      'mocha',
      'notify'
    ]
  };
};

You can specify a task description - example JavaScript file grunt/aliases.js

module.exports = {
  'lint': {
    description: 'Lint css and js',
    tasks: [
      'jshint',
      'csslint'
    ]
  }
};

Custom Config

There are certain scenarios where you might have a base config for your team, and you want to be able to override some of the config based on your personal setup. You can do that with the overridePath property. In this case, the library will merge the two, with the override path taking priority. For example:

module.exports = function(grunt) {
  var path = require('path');
  
  require('load-grunt-config')(grunt, {
    configPath: path.join(process.cwd(), 'vendor'),
    overridePath: path.join(process.cwd(), 'config-'+process.env.USER)
  });

};

configPath and overridePath accept single string as well as array of strings. It means that you can compose config using multiple folders. For example:

module.exports = function(grunt) {
  var path = require('path');
  
  require('load-grunt-config')(grunt, {
    configPath: [
      path.join(process.cwd(), 'vendor'),
      path.join(process.cwd(), 'base-target')
    ],
    overridePath: [
      path.join(process.cwd(), 'variant-1'),
      path.join(process.cwd(), 'variant-n')
    ]
  });

};

Config Grouping

load-grunt-config also supports grouping tasks. This is handy when you want to group all of your script or css tasks together. To do that, just add the suffix -tasks to your config filename and load-grunt-config will treat the filename as the task target and the top level keys as the task names.

Here's an example

Filename: /config/scripts-tasks.yaml

jshint:
  files:
    - '*.js'
jshint__test:
  files:
    - 'test/*.js'
watch:
  files:
    - '*.js'
  tasks:
    - 'scripts'

This would be the equivalent in your Gruntfile.js:

{
  jshint: {
    scripts: {
      files: [
        '*.js'
      ]
    },
    scripts_test: {
      files: [
        'test/*.js'
      ]
    }
  },
  watch: {
    scripts: {
      files: [
        '*.js'
      ],
      tasks: [
        'scripts'
      ]
    }
  }
}

Debugging

If you pass the parameter --config-debug, load-grunt-config will output the whole object it will pass to Grunt, which can be useful for debugging purposes or when asking for help.

Note that this won't run grunt at all and no tasks would be run, nor loaded.

load-grunt-config's People

Contributors

akritiayu avatar danielcreid avatar danielkcz avatar defaude avatar dependabot[bot] avatar dfernandez79 avatar dylang avatar ferrybig avatar greenkeeper[bot] avatar itkoren avatar jgallen23 avatar jigardafda avatar khamasaki avatar luisfmsouza avatar mrmlnc avatar pradeek avatar rafhun avatar rejas avatar rogozhka avatar schmengler avatar sebdeckers avatar shinnn avatar solomon-ua avatar tawez avatar travi avatar vencha90 avatar wolfflow avatar zypa13510 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

load-grunt-config's Issues

Version 10 not working with usemin

showing warning: task "default" not found, use --force to continue.
Aborted due to warnings. it is working without load-grunt-config.

This is my gruntfile which is as per instructions.
module.exports = function(grunt) {
require('load-grunt-config')(grunt);
};

my package.json shows this
{
"name": "appname",
"version": "0.0.1",
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-concat": "^0.4.0",
"grunt-contrib-uglify": "^0.5.0",
"load-grunt-config": "^0.10.0"
}
}

i have made a folder 'grunt' in exactly where Gruntfile.js is, which containg uglify.js which contains this with correct file urls:

module.exports = {
dist: {
files: {
'shop/production.min.js': ['shop/production.js']
}
}
};

also it works if i add this line:
grunt.registerTask('default', ['uglify']);

--config-debug flag

grunt --config-debug to just output what load-grunt-config is sending to grunt without actually running grunt. Will be useful for debugging issues with people's configs

Can't use <%= package.var %> in data config

I'm trying to use the "data" property for adding additional configuration variables that can be used in the task files:

Gruntfile.js

// load grunt config
    require('load-grunt-config')(grunt, {
        data: {
            appPath: "<%= package.appPath %>",
            cssPath: "<%= package.appPath %>/css",
            jsPath: "<%= package.appPath %>/js",
            tplPath: "<%= package.appPath %>/templates"
        }
    });

csslint.js

files: ["<%= cssPath %>/jquery-ui/themes/itracs/jquery-ui.css", "<%= cssPath %>/main.css", "<%= cssPath %>/cpim/*.css"],
    options: {
        csslintrc: "<%= cssPath %>/.csslintrc"
}

When I run grunt I get the following error:

Running "csslint:files" (csslint) task
Warning: An error occurred while processing a template (Cannot read property 'appPath' of undefined). Use --force to continue.
TypeError: An error occurred while processing a template (Cannot read property 'appPath' of undefined).
    at eval (/lodash/template/source[2]:6:22)
    at Function.template (/Users/ewaibel/git-repos/webui/node_modules/grunt/node_modules/lodash/lodash.js:3879:14)
    at Object.template.process (/Users/ewaibel/git-repos/webui/node_modules/grunt/lib/grunt/template.js:75:27)
    at /Users/ewaibel/git-repos/webui/node_modules/grunt/lib/grunt/config.js:75:27
    at recurse (/Users/ewaibel/git-repos/webui/node_modules/grunt/lib/grunt/util.js:116:12)
    at /Users/ewaibel/git-repos/webui/node_modules/grunt/lib/grunt/util.js:105:14
    at Array.map (native)
    at Object.recurse (/Users/ewaibel/git-repos/webui/node_modules/grunt/lib/grunt/util.js:104:18)
    at Function.config.process (/Users/ewaibel/git-repos/webui/node_modules/grunt/lib/grunt/config.js:61:21)
    at Function.config.get (/Users/ewaibel/git-repos/webui/node_modules/grunt/lib/grunt/config.js:55:17)

Multiple config load paths

We're using load-grunt-config in ember app kit. You previously said that you want to allow multiple config loading paths. How's the progress on that? Thanks!

Proposed solution:
configPath: ['path1', 'path2ThatOverwritesOptionsFromPath1']

Our crappy solution:
stefanpenner/ember-app-kit#409

Support for multiple 'aliases' files

I have many aliases, some specific to a particular phase of the build process, some specific to certain environments. It would suit me, then, to have the ability to define aliases in multiple files.

I have looked at all the source - of which there is a deceivingly small amount - in 0.8.0-beta.2 and cannot spot a reason why having multiple alias files wouldn't work. The only theory I can produce is that Grunt places special significance in the property name aliases. I could be totally wrong, though.

To accomplish my need, https://gist.github.com/greghopkins/68f8feff80762fa9b58b.

Is there a way to accomplish this, while being true to the spirit of your framework?

Thanks!

More specific function example

Thanks for writing this awesome plugin! However, would it be possible to include a more specific example of returning a function with load-grunt-config? Because it might just be me, but from the example in the docs I'm unable to figure out how exactly you would do this. I can see how you would define a function, but what exactly would you do to call the function? Just standard js doesn't seem to work and I'm running in to all kinds of errors.

Of course this is probably all me, but more specific examples would be extremely helpful. For example: is it possible to define a function as a separate file (e.g. scanForTemplates.js) and call it from within another task? See this stack overflow question for an use case which requires this.

Cannot use both approaches

For any reason,

if I keep half of my configured grunt-tasks in my Gruntfile.js,
configured by e.g. concat : {...}
it will not find the target e.g. html2js, which is in grunt/html2.js.

is this known?

imagemin not working using load-grunt-config tasksfile imagemin.js

I have placed this line which is a module used by imagemin in my gruntfile below
var mozjpeg = require('imagemin-mozjpeg');

It shows warnings like
Loading "Gruntfile.js" tasks...ERROR

ERROR: Cannot find module 'imagemin-mozjpeg'

or

Fatal Error: Cannot read property 'contents' of undefined

however it works well on png images, all this happends after finishing png files processing i guess.

Example from documentation does not work

When I use the example (Basic Gruntfile.js):

require('load-grunt-config')(grunt);

There are no errors and it works fine. However, when using the second example (Gruntfile.js with options) from the documentation:

module.exports = function(grunt) {

    require('load-grunt-config')(grunt, {
        configPath: path.join(process.cwd(), 'grunt'), //path to task.js files, defaults to grunt dir
        init: true, //auto grunt.initConfig
        data: { //data passed into config.  Can use with <%= test %>
            test: false
        },
        loadGruntTasks: { //can optionally pass options to load-grunt-tasks.  If you set to false, it will disable auto loading tasks.
            pattern: 'grunt-*',
            config: require('./package.json'),
            scope: 'devDependencies'
        }
    });

};

I get the error ReferenceError: path is not defined. So there seems to be a problem with the second example. Which is a shame since it provides the syntax you would use when you want to define a custom directory (which now, does not work).

I solved this by using:

  require('load-grunt-config')(grunt, {
    configPath: process.cwd() + '/_grunt'
  });

Which does work. Please update the example so it works. Thanks!

Best-Practice: Add function-callback support for tasks in e.g. grunt/aliases.yaml

Add function-callback support for tasks in grunt/aliases.yaml

My use-case: I'd like to react on the result of a predefined task
like nodeunit to e.g. prompt to ingore failture.
The same goes for custom registeredTasks.

or e.g. the connect proxy task:

grunt.registerTask('server', function (target) {
    grunt.task.run([
        'configureRewriteRules',

        'connect:mypage',
        'open:page'

    ]);
});

How do you suggest perform?

Thanks

Ability to define descriptions in aliases file

Would be nice to have the ability to put descriptions with the aliases declared in the aliases file.

Perhaps we can change this segment to something like this:

  if (aliases) {
    for (var taskName in aliases) {
        var task = aliases[taskName];
        if (typeof task === 'string' || Array.isArray(task))
            grunt.registerTask(taskName, aliases[taskName]);
        else {
            grunt.registerTask(taskName, task.description, task.aliases);
        }
    }
  }

that way aliases can be like this:

{
    //================
    "default": [ 
        "compile"
    ],
    //================
    "compile": { 
        description: "some description",
        tasks: [
            "shell:someCompile"
        ]
    },
    //================
    "watch": [ 
        "shell:someWatch"
    ]
}

JSON files

Hey,
It's real that no one ever thought of using .json files? It should definitely be added to the list of allowed extensions.

Thanks in advance!!

Grunt task not loading when part of an alias

I've stumbled upon a weird bug and I suspect it has something to do with load-grunt-config. On line 93 of my aliases file there is a reference to load grunt modernizr. When I uncomment this line and run grunt build, I get the error:

>> No "modernizr" targets found.
Warning: Task "modernizr" failed. Use --force to continue.

When I change line 93 to modernizr:dist, this is the error I get when running grunt build:

Running "modernizr:dist" (modernizr) task
Verifying property modernizr.dist exists in config...ERROR
>> Unable to process task.
Warning: Required config property "modernizr.dist" missing. Use --force to continue.

The weird thing is, when I just try running grunt modernizr:dist or grunt modernizr from the command line, it works just fine. All other tasks and aliases work fine too. So it seems that load-grunt-config is not able to load modernizr's config in this one, specific case. Any idea what's going wrong (I can include --verbose output if that's useful)?


By the way, at the time of this bug I was using 0.9.2.

Dynamically add tasks

I've been running into problems using load-grunt-config and usemin. When useminPrepare dynamically creates the settings for concat and uglify tasks (to be used by usemin), those "generated:" targets are not stored in the grunt.config.data object!

Any current way around this?

Thanks!

Variable passed in config return undefined when use directly

Variable passed in config work fine when used in string (["<%= ref.src %>/**/*.js"]) but return undefined when used directly (ref.src)

Example:

Gruntfile.js

module.exports = function(grunt) {

    require('load-grunt-tasks')(grunt);

    var ref = {
        src: "src",
        dist: "www",
        livereload: 9001
    };

    require('load-grunt-config')(grunt, {
        config: {
            ref: ref
        }
    });
};

grunt/watch.js

module.exports = function(grunt) {
    return {
        options: {
            livereload: ref.livereload
        },
        app: {
            files: ["<%= ref.src %>/**/*.js"],
            tasks: ["jshint:app"]
        }
    }
}

the ["<%= ref.src %>/**/*.js"] part is working fine, but ref.livereload will return undefined.

One workaround for me has been to force those variable in global variable using global.ref = ref;, but surely is they're pass through the config options, they should be available directly.

Aside from that little issue, Thank you for the amazing work done on this plugin, it saved me hours of task config and I can finally look at my Gruntfile.js whiteout crying!

Doesn't work grunt-contrib-watch.

First time tried to split my Gruntfile into pieces, and pretty much it all works except grunt-contrib-watch, and that's a bummer.

This is my watch.js file:

module.export = {
    sass: { 
        files: ['**/*.scss'], 
        tasks: ['sass', 'autoprefixer', 'cssmin']
    }
};

And aliases.yaml

default:
  - 'sass'

And this is what I instantly get
watchjs

If I change Gruntfile to my all-in-one version (which is share the same code), it works normal.

Any ideas?)

P.S. grunt command without watch task in aliases works flawlessly, of course

How to pass a variable to a config file?

I've got the following configuration:

connect: {
  livereload: {
    options: {
      middleware: function (connect) {
        return [
          modRewrite([
            '!\\.ttf|\\.woff|\\.ttf|\\.eot|\\.html|\\.js|\\.css|\\.png|\\.jpg|\\.gif|\\.svg$ /index.html [L]'
          ]),
          lrSnippet,
          mountFolder(connect, '.tmp'),
          mountFolder(connect, yeomanConfig.app)
        ];
      }
    }
  }
}

It looks like the following syntax is supported:

module.exports = function (grunt) {
    return { /* ... */ };
};

and modRewrite and lrSnippet variables are local to this config, so it's not a problem, but yeomanConfig is shared with other tasks as well. Is there any way to pass it there?

Issue loading tasks.

Hi.

I have run into problems using load-grunt-config with tasks such as grunt-regex-replace and grunt-html-snapshots.

I have had success with the following tasks:

  • grunt-contrib-jshint
  • grunt-contrib-clean
  • grunt-contrib-concat
  • grunt-contrib-uglify
  • grunt-contrib-copy

But I have had difficulties with these tasks:

  • grunt-regex-replace
  • grunt-html-snapshots

I did manage to get grunt-regex-replace to work by adding the following to my Gruntfile.js file:

grunt.loadNpmTasks('grunt-regex-replace');

After adding the above to my Gruntfile.js the task ran as expected and the config was loaded from grunt/regex-replace.js.

However the same approach did not work for grunt-html-snapshots and in this case, I had to also include the config inside the Gruntfile.js file (essentially bypassing load-grunt-config completely for this particular task).

Example

Gruntfile.js

module.exports = function(grunt) {      
    require('load-grunt-config')(grunt);
};                                      

package.json (truncated)

{                                                         
  ...
  "dependencies": {                                       
    "load-grunt-config": "~0.8.0-beta.1"                  
  },                                                      
  "devDependencies": {                                    
    "load-grunt-config": "^0.8.0-beta.1",                 
    "grunt-html-snapshots": "^0.2.0"                      
  },                                                      
  ...
}                                                         

aliases.yaml

default:            
 - 'html-snapshots' 

I can verify that there is also a html-snapshots.js file in the grunt folder.

$ ls grunt                        
aliases.yaml  html-snapshots.js   

I haven't included the contents of this file because I don't believe it's relevant?

Thanks!

Attempts to load files other than js, yaml and coffee

The glob that loads tasks is a simple * glob. This needs to be filtered down to just js, yaml and coffee files only. I'm having issues with my TypeScript files as well as the sourcemaps throwing errors when this glob tries to load them as JavaScript files.

register-task.yaml

Be able to define tasks in a register-task.yaml (or maybe aliases.yaml).

default:
  - jshint
  - concat
prod:
  - uglify
dev:
  - default
  - connect
  - watch

@williamsb @CBas @dylang @belelros @dawnerd Do you guys have any thoughts on this? Would you use it?

Infinite loop when running 'watch' alias

I was attempting to run 'grunt watch' after creating my watch.js configuration:

module.exports = {
    files: ['./index.html'],
    options: {
        livereload: true,
        port: 666
    },
    tasks: ['jshint']
};

and I was presented with a constant barrage of messages:

...
Running "watch" task
Waiting...Verifying property watch exists in config...ERROR
>> Unable to process task.
Warning: Required config property "watch" missing.

Running "watch" task
Waiting...Verifying property watch exists in config...ERROR
>> Unable to process task.
Warning: Required config property "watch" missing.

Running "watch" task
Waiting...Verifying property watch exists in config...ERROR
>> Unable to process task.
Warning: Required config property "watch" missing.
...

The only way I could exit was hitting Ctrl-C to kill the process.

clean.server missing?

I've got a clean task and in it I have the following:

module.exports = function(grunt) {
    return {
        dist: [
            '.tmp',
            '<%= yeoman.dist %>/*'
        ],
        server: ['.tmp'],
        cq: {
            src: [
                '<%= yeoman.cq %>/css',
                '<%= yeoman.cq %>/images',
                '<%= yeoman.cq %>/js'
            ],
            options: {
                force: true
            }
        },
        hooks: {
            src: ['../.git/hooks/pre-commit'],
            options: {
                force: true
            }
        }
    }
};

load-grunt-config acknowledges the clean task but when i run a task that uses clean:server (or just grunt clean:dist or any other for that matter) I see this:

Running "clean:server" (clean) task
Verifying property clean.server exists in config...ERROR

Any idea why I'm getting this? Thanks in advance.

configPath confusion

It seems that options.configPath is used as is first in glob.sync('*', {cwd: options.configPath} but then is used with cwd prepended a couple lines below in path.join(cwd, options.configPath, option).

This inconsistency is giving me problems where I can either have glob find my files or make fulllPath correct, but not both.

Full code:

var cwd = process.cwd();

  glob.sync('*', {cwd: options.configPath}).forEach(function(option) {
    key = option.replace(/\.(js|yaml)$/,'');
    var fullPath = path.join(cwd, options.configPath, option);

Is there a way to exclude packages?

I have to packages with the same task name. So I would like to be able to load one in manually so I can rename it, but I can't figure out a way to exclude it from loading in.
Can the pattern option take exclusions? It's doesn't seem to be working for me.

this for the current task is not present

Hi,

do you have a quick solution how to do something like:

//Custom InitVariables tasks
module.exports = function (grunt) {

var func = function(grunt){
var done = this.async();
}

this is related to grunt, not the current task.

Thanks

Using angular-templates

I'm trying to use load-grunt-config with grunt-angular-templates.
The error is "Warning: An error occurred while processing a template (Cannot read property 'dist' of undefined). Use --force to continue." and it references to '<%= ngtemplates.dist.dest %>' in my concat task.

So it seems there is no global var ngtemplates, i have added a global var like this before.

config: {
yeoman: yeomanConfig
}

But i am a little confused on how to add another task to the global config.

Object #<Object> has no method 'replace' error for tasks with a description

With 0.10.0 and the new option to add descriptions to tasks in the aliases.yaml file, I'm unable to run tasks for which I've added a description. With the following code in aliases.yaml:

build:
  description: 'Build static website for deployment'
  tasks:
    - 'clean:temp'
    - 'clean:dist'
    - 'check_src'
    - 'format_src'
    - 'build_dist'
    - 'usemin_dist'
    - 'process_dist'
    - 'clean:temp'

I get the error: Warning: Object #<Object> has no method 'replace' Use --force to continue.

Grunt --help gives the following description for the build alias: build Alias for "[object Object]" task.

Other tasks (to which I haven't added a description), run just fine. The full syntax of my aliases.yaml before adding the description to the build task is here.

Problem using jit-grunt and static mappings

I'm using the jit-grunt option to load tasks, but I'm having trouble getting it to work with grunt-prompt - it requires a static mapping, but when I do that it still doesn't work.

Here's my Gruntfile:

module.exports = function(grunt)
{
    require('load-grunt-config')(grunt, {
        jitGrunt: {
            prompt: 'grunt-prompt'
        }
    });
};

And here's the error message:

jit-grunt: Plugin for the "interactiveBuild" 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 "interactiveBuild" not found. Use --force to continue.

My directory structure is standard - Node packages in node_modules, Grunt config files in a directory called grunt.

Any ideas?

Review how configuration groups are handled

I run into the same problem fixed by 5c64e84, to realise that the way in which configuration groups is handled is not useful to me.

Right now each task in xyz-tasks is translated to task:xyz, but what happens when you have multiple task configurations in your group?

For example, I've a build like this:

docs-tasks.coffee

module.exports = (grunt) ->
   copy:
      targetA:
          # src and dest for targetA
      targetB:
         # src and dest for targetB

The problem is that the default task group behavior will generate:

copy:
    docs:
         targetA:
         targetB:

Which is incorrect. I know that this is how the library defines the handling of config groups, my argument is that the current way of handling groups is not very useful.

Probably you'll ask why I have two copy configurations instead of using multiple file patterns... the problem is that I'm using the process function to transform some files, and I cannot pass that function in a pattern, so I'm forced to use multiple configs. But the copy task is irrelevant, I also have configurations like that for the watch task, because it allows me to reduce the number of tasks executed when something changes, for example:

watch:
    styles: files: groupA tasks: styleProcessTasks
    jade: files: groupB tasks: jadeCompiler

Include grunt with aliases.js file?

I'd like to make use of grunt.config in the aliases.js file, but it doesn't seem to act like the task.js files.

I tried this

module.exports = function(grunt) {
  return {
  "default": 'build',
  "build:scripts": grunt.config.get('optimize') ? ['jshint', 'browserify', 'uglify'] : ['jshint', 'browserify']
  };
};

I wanted to test a config option and run different items based on that, but when the aliases.js is set up like this, then no tasks are registered.

Is this just not possible? Is there a better way?

Thanks,

prevent to cache modules

When use require loading json , js , coffee and |s files should delete the cached modules first. I find this issue when I'am trying to use grunt-contrib-watch for watching the task files chang, so the plugin will reload specific tasks. Unfortunately, because of the cache, the load-grunt-config can't get the newest files.

This can be easily done by:

// JS / JSON / CoffeeScript
if (ext.match(/json|js|coffee|ls/)) {
    delete require.cache[file]; // delete the cached modules
    return require(file);
}

I am looking forward to your reply.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.