优化器应该拾取所有指定为依赖项的文件。如果您需要包含额外的内容,则可以使用 onBuildRead 或 onBuildWrite 回调添加额外的逻辑,您可以在其中添加/删除额外的内容:
({
name: 'main',
baseUrl: '../',
// optimize: 'none',
optimize: 'uglify2',
exclude: ['jquery'],
mainConfigFile: '../main.js',
out: '../main.min.js',
// A function that if defined will be called for every file read in the
// build that is done to trace JS dependencies.
// Remove references to console.log(...)
onBuildRead: function (moduleName, path, contents) {
return contents;
// return contents.replace(/console.log(.*);/g, '');
},
onBuildWrite: function (moduleName, path, contents) {
// Add extra stufff;
return contents;
}
})