Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gruntjs Grunt配置函数省略_Gruntjs_Grunt Usemin - Fatal编程技术网

Gruntjs Grunt配置函数省略

Gruntjs Grunt配置函数省略,gruntjs,grunt-usemin,Gruntjs,Grunt Usemin,我试图在useminPrepare配置中定义一个自定义函数,但无论我做什么,最终在构建中都会忽略该函数 我已将Node0.10.36和NPM2.4.1更新为最新版本 配置文件: useminPrepare: { src: options.dist.dir + '/index.html', options: { dest: options.dist.dir + '/', staging: options.temp.dir, flow

我试图在useminPrepare配置中定义一个自定义函数,但无论我做什么,最终在构建中都会忽略该函数

我已将Node0.10.36和NPM2.4.1更新为最新版本

配置文件:

useminPrepare: {
    src: options.dist.dir + '/index.html',
    options: {
        dest: options.dist.dir + '/',
        staging: options.temp.dir,

        flow: {
            steps: {
                js: ['concat', 'uglifyjs']
            },
            post: {
                js: [
                    {
                        name: 'concat',
                        createConfig: function(a,b) {
                            console.log(a,b);
                        }
                    },
                    'uglifyjs'
                ]
            }
        }
    }
}
Grunt生成详细通知createConfig已消失:

Running "useminPrepare:useminPrepare" (useminPrepare) task
Verifying property useminPrepare.useminPrepare exists in config...OK
Files: dist/index.html
Options: dest="dist/", staging=".tmp", flow={"steps":{"js":["concat","uglifyjs"]},"post":{"js":[{"name":"concat"},"uglifyjs"]}}
Going through dist/index.html to update the config
Looking for build script HTML comment blocks
有人知道吗

如果我使用函数作为值指定自己的参数,它也会忽略。如果我指定字符串,它不会被忽略:

name: 'concat',
test: function() {
    console.log("Hello world");
},
createConfig: function() {
    console.log(a,b);
}

我知道我做错了什么,我应该在子任务之外指定选项,比如:

useminPreprare: {
    options: {
        dest: options.dist.dir + '/',
        staging: options.temp.dir,

        flow: {
            steps: {
                js: ['concat', 'uglifyjs'],
                css: ['concat', 'cssmin']
            },
            post: {
                js: [
                    {
                        name: 'concat',
                        createConfig: function(a,b) {
                            console.log(a,b);
                        }
                    },
                    'uglifyjs'
                ]
            }
        }
    },
    build: {
        src: options.dist.dir + '/index.html',
    }
}

现在我可以执行useminPrepare任务useminPrepare:build

你说它省略了什么意思?该函数不会执行,并且没有在build verbose中的选项下定义。你打算如何访问它?我已经尝试过Git bash和windows cmd sofar。我还尝试清理我的npm缓存并重新安装所有模块。