在我的grunt-contrib-requirejs任务停止我的咕噜进程时,我遇到了一个问题。它这样做完全没有错误。我需要帮助找出问题所在。
我的总体任务
grunt.registerTask('build', [
'clean:dist',
'jshint',
'handlebars',
'requirejs',
'concat:dist',
'uglify',
'compass',
'imagemin',
'cssmin',
'copy'
]);这是我的任务配置
requirejs: {
dist: {
options: {
baseUrl: 'app',
optimize: 'none',
optimizeCss: 'none', // We use cssmin for this
preserveLicenseComments: true,
dir: 'dist/',
useStrict: true,
wrap: false,
findNestedDependencies: true,
//If set to true, any files that were combined into a build bundle will be
//removed from the output folder.
removeCombined: true,
paths: {
aura: '<%= settings.bower %>/aura/lib/aura',
underscore: '<%= settings.bower %>/underscore/underscore',
eventemitter: '<%= settings.bower %>/eventemitter2/lib/eventemitter2',
backbone: '<%= settings.bower %>/backbone/backbone',
handlebars: '<%= settings.bower %>/handlebars/handlebars',
text: '<%= settings.bower %>/requirejs-text/text',
jquery: '<%= settings.bower %>/jquery/jquery'
},
shim: {
backbone: {
exports: 'Backbone',
deps: ['underscore', 'jquery']
},
underscore: {
exports: '_'
},
handlebars: {
exports: 'Handlebars'
}
},
modules: [{
name: "app",
include: ["aura","jquery"]
}],
onBuildWrite: function( name, path, contents ) {
grunt.log.writeln( 'Writing: ' + name );
return contents
},
done: function(done, output) {
var duplicates = require('rjs-build-analysis').duplicates(output);
if (duplicates.length > 0) {
grunt.log.subhead('Duplicates found in requirejs build:');
grunt.log.warn(duplicates);
done(new Error('r.js built duplicate modules, please check the excludes option.'));
}
grunt.log.writeln('All done');
done();
}
}
}
}我尝试使用-v标志运行它,但没有收到任何错误或警告。然后它就会停止,不运行我定义的其他任务,也不会得到我定义的自定义日志。我得到了这个输出:
Running "requirejs" task
Running "requirejs:dist" (requirejs) task
Verifying property requirejs.dist exists in config...OK
File: [no files]
Options: logLevel=0, done=undefined, baseUrl="app", optimize="none", optimizeCss="none", preserveLicenseComments, dir="dist/", useStrict, wrap=false, findNestedDependencies, removeCombined, paths={"aura":"bower_components/aura/lib/aura","underscore":
"bower_components/underscore/underscore","eventemitter":"bower_components/eventemitter2/lib/eventemitter2","backbone":"bower_components/backbone/backbone","handlebars":"bower_components/handlebars/handlebars","text":"bower_components/requirejs-text/t
ext","jquery":"bower_components/jquery/jquery"}, shim={"backbone":{"exports":"Backbone","deps":["underscore","jquery"]},"underscore":{"exports":"_"},"handlebars":{"exports":"Handlebars"}}, modules=[{"name":"app","include":["aura","jquery"]}], onBuild
Write=undefined
>> Tracing dependencies for: app从这个输出看来,done函数是没有定义的,但是我确实定义了它,我甚至使用了要求的自述中的一个示例。
我用的是grunt@0.4.1和grunt-contrib-requirejs@0.4.1和requirejs@2.1.8。节点是版本v0.8.16
更新一
我试着升级我的节点,我现在在v0.10.17上,但是这里没有任何变化。
我从模块包含中删除了aura,现在看起来如下所示:
modules: [{
name: "app",
include: ["jquery"]
}],这给了我更多的输入,但是它仍然停止了我的Grunt,并且没有运行我的done函数,我得到了这个输出:
>> app.js
>> ----------------
>> bower_components/aura/lib/platform.js
>> bower_components/aura/lib/base.js
>> bower_components/aura/lib/logger.js
>> bower_components/aura/lib/aura.extensions.js
>> bower_components/aura/lib/aura.js
>> app.js发布于 2014-02-26 02:28:45
问题是您的done函数失败了,并且grunt任务没有被设置为将错误转发给您。我做了一个你可以在这里看到来解决这个问题。
发布于 2013-09-02 10:04:55
我在GitHub上发现了我的问题:https://github.com/gruntjs/grunt-contrib-requirejs/issues/37
但目前还没有解决办法,我自己可能不得不正视这个错误。
发布于 2014-02-06 15:54:35
如果从requireJS选项中删除整个“完成”部分,它将不会停止任务列表执行,但是您将失去对已编译代码执行分析的能力。
https://stackoverflow.com/questions/18402415
复制相似问题