1. 判断成员是否是一个函数:

if (typeof options.sourceMapName === 'function') {

mapNameGenerator = options.sourceMapName;

}

 

  1. Try/Catch

var result;

try {

result = uglify.minify(availableFiles, f.dest, options);

} catch (e) {

console.log(e);

err = new Error('Uglification failed.');

if (e.message) {

err.message += '\n' + e.message + '. \n';

if (e.line) {

err.message += 'Line ' + e.line + ' in ' + availableFiles + '\n';

}

}

err.origError = e;

grunt.log.warn('Uglifying source ' + chalk.cyan(availableFiles) + ' failed.');

grunt.fail.warn(err);

}

 

  1. 将一个数组里面的值用某个符号拼接起来。

var unCompiledJSString = availableFiles.map(function (file) {

return grunt.file.read(file);

}).join('');

 

 

相关文章:

  • 2022-12-23
  • 2021-10-08
  • 2021-11-09
  • 2021-08-20
  • 2022-12-23
  • 2021-06-12
猜你喜欢
  • 2021-08-14
  • 2021-07-30
  • 2021-07-13
  • 2022-12-23
  • 2021-08-19
  • 2021-08-23
  • 2021-11-18
相关资源
相似解决方案