Add prefix option.
Same as `-p` and `--prefix` in CLI.
This commit is contained in:
parent
1a5fe196b3
commit
9a14825a1a
|
|
@ -59,6 +59,7 @@ exports.minify = function(files, options) {
|
||||||
warnings : false,
|
warnings : false,
|
||||||
mangle : {},
|
mangle : {},
|
||||||
output : null,
|
output : null,
|
||||||
|
prefix : null,
|
||||||
compress : {}
|
compress : {}
|
||||||
});
|
});
|
||||||
if (typeof files == "string")
|
if (typeof files == "string")
|
||||||
|
|
@ -70,6 +71,11 @@ exports.minify = function(files, options) {
|
||||||
var code = options.fromString
|
var code = options.fromString
|
||||||
? file
|
? file
|
||||||
: fs.readFileSync(file, "utf8");
|
: fs.readFileSync(file, "utf8");
|
||||||
|
|
||||||
|
if (options.prefix !== null) {
|
||||||
|
file = file.replace(/^\/+/, "").split(/\/+/).slice(options.prefix).join("/");
|
||||||
|
}
|
||||||
|
|
||||||
toplevel = UglifyJS.parse(code, {
|
toplevel = UglifyJS.parse(code, {
|
||||||
filename: options.fromString ? "?" : file,
|
filename: options.fromString ? "?" : file,
|
||||||
toplevel: toplevel
|
toplevel: toplevel
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user