fis-optimizer-uglify-js
Advanced tools
Comparing version 0.1.8 to 0.1.9
122
index.js
@@ -10,6 +10,126 @@ /* | ||
function uglify(content, file, conf) { | ||
conf.fromString = true; | ||
if (conf.sourceMap) { | ||
var mapping = fis.file.wrap(file.dirname + '/' + file.filename + '.map'); | ||
conf.outSourceMap = file.filename + '.org' + file.rExt; | ||
} | ||
var ret = UglifyJS.minify(content, conf); | ||
if (conf.sourceMap) { | ||
mapping.useDomain = true; | ||
mapping.useHash = true; | ||
var mapData = JSON.parse(ret.map); | ||
mapData.sources = [mapData.file]; | ||
mapData.sourcesContent = [content]; | ||
var newData = { | ||
version: mapData.version, | ||
file: mapData.file, | ||
sources: mapData.sources, | ||
sourcesContent: mapData.sourcesContent, | ||
names: mapData.names, | ||
mappings: mapData.mappings | ||
}; | ||
mapping.setContent(JSON.stringify(newData)); | ||
file.extras = file.extras || {}; | ||
file.extras.derived = file.extras.derived || []; | ||
file.extras.derived.push(mapping); | ||
ret.code += '\n//# sourceMappingURL=' + mapping.getUrl(fis.compile.settings.hash, fis.compile.settings.domain); + '\n'; | ||
} | ||
return ret.code; | ||
} | ||
module.exports = function(content, file, conf){ | ||
try { | ||
content = uglify(content, file, conf); | ||
} catch (e) { | ||
fis.log.warn('Got Error %s while uglify %s', e.message, file.subpath); | ||
fis.log.debug(e.stack); | ||
} | ||
return content; | ||
}; | ||
/* | ||
* fis | ||
* http://fis.baidu.com/ | ||
*/ | ||
'use strict'; | ||
var UglifyJS = require('uglify-js'); | ||
module.exports = function(content, file, conf){ | ||
conf.fromString = true; | ||
if (conf.sourceMap) { | ||
conf.outSourceMap = file.filename + '.org' + file.rExt; | ||
conf.outSourceMap =/* | ||
* fis | ||
* http://fis.baidu.com/ | ||
*/ | ||
'use strict'; | ||
var UglifyJS = require('uglify-js'); | ||
function uglify(content, file, conf) { | ||
conf.fromString = true; | ||
if (conf.sourceMap) { | ||
var mapping = fis.file.wrap(file.dirname + '/' + file.filename + '.map'); | ||
conf.outSourceMap = file.filename + '.org' + file.rExt; | ||
} | ||
var ret = UglifyJS.minify(content, conf); | ||
if (conf.sourceMap) { | ||
mapping.useDomain = true; | ||
mapping.useHash = true; | ||
var mapData = JSON.parse(ret.map); | ||
mapData.sources = [mapData.file]; | ||
mapData.sourcesContent = [content]; | ||
var newData = { | ||
version: mapData.version, | ||
file: mapData.file, | ||
sources: mapData.sources, | ||
sourcesContent: mapData.sourcesContent, | ||
names: mapData.names, | ||
mappings: mapData.mappings | ||
}; | ||
mapping.setContent(JSON.stringify(newData)); | ||
file.extras = file.extras || {}; | ||
file.extras.derived = file.extras.derived || []; | ||
file.extras.derived.push(mapping); | ||
ret.code += '\n//# sourceMappingURL=' + mapping.getUrl(fis.compile.settings.hash, fis.compile.settings.domain); + '\n'; | ||
} | ||
return ret.code; | ||
} | ||
module.exports = function(content, file, conf){ | ||
try { | ||
content = uglify(content, file, conf); | ||
} catch (e) { | ||
fis.log.warn('Got Error %s while uglify %s', e.message, file.subpath); | ||
fis.log.debug(e.stack); | ||
} | ||
return content; | ||
}; | ||
file.filename + '.org' + file.rExt; | ||
} | ||
@@ -16,0 +136,0 @@ |
{ | ||
"name" : "fis-optimizer-uglify-js", | ||
"description" : "A optimizer for fis to compress js by using uglify-js.", | ||
"version" : "0.1.8", | ||
"version" : "0.1.9", | ||
"author" : "FIS Team <fis@baidu.com>", | ||
@@ -6,0 +6,0 @@ "homepage" : "http://fis.baidu.com/", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
6166
117