Q:

How to move a function outside of Gruntfile.js?

I have a function my_function in Gruntfile.js as following:
// Gruntfile.js

module.exports = function(grunt) {

    var config = my_function(grunt);

    grunt.initConfig(config);
};

function my_function(grunt) {
    //some code
    return config;
}

It works perfectly but now I want to move the function to another file, how do I do that?

A:

Just make an another module.
func.js
module.exports = (function() { console.log(1); })();

gruntfile
var myFunc = require("./func.js");

