function uglify(content, file, conf) { conf.fromString = true; try{ //prod模式下browserify后的文件都必须带有sourcemap conf.inSourceMap = JSON.parse(convert.fromComment(getSM(content, file)).toJSON()); }catch(e){ conf.inSourceMap = null; } if (conf.sourceMap) { conf.outSourceMap = file.filename + '.org' + file.rExt; } var ret = UglifyJS.minify(content, conf); if (conf.sourceMap) { ret.code = ret.code.replace(/\/\/\# sourceMappingURL\=.*/g, ''); var hash = file.getHash(); var filenameWithHash = file.filename + '_' + hash; var smapPath = fis.project.getProjectPath('/sourcemap/' + filenameWithHash + '.map'); fis.util.write(smapPath, ret.map, 'utf-8', false); } return ret.code; }
save: function() { fis.util.write(this.filePath, JSON.stringify(this.fileSigs, null, this.fileSpace)); return this; },