parent
1c81e12fd8
commit
97bb6f3a33
@ -0,0 +1,22 @@ |
||||
"use strict"; |
||||
|
||||
const fs = require('fs'); |
||||
const path = require('path'); |
||||
const UglifyJS = require("uglify-js"); |
||||
|
||||
module.exports = (params, processor) => ({ |
||||
process: () => { |
||||
const filePath = path.normalize(processor.context.exported + "/" + params.filename); |
||||
const result = UglifyJS.minify(filePath); |
||||
fs.writeFile(filePath, result.code, (err) => { |
||||
if (err) { |
||||
processor.onError("Unable to write uglified script for " + params.filename + ": " + err); |
||||
} else { |
||||
processor.onInfo("Saved uglified script for " + params.filename + "; uglified length: " + result.code.length); |
||||
} |
||||
|
||||
processor.done(); |
||||
}); |
||||
} |
||||
}); |
||||
|
@ -0,0 +1,36 @@ |
||||
"use strict"; |
||||
|
||||
const glob = require('glob'); |
||||
|
||||
module.exports = (params, processor) => ({ |
||||
process: () => { |
||||
if (processor.context.uglifyjsallDone) { |
||||
processor.onWarn("dotnetnunitall task is executed more than once; this is probably a bug in your mbs.json"); |
||||
} |
||||
|
||||
processor.context.uglifyjsallDone = true; |
||||
|
||||
glob("**/*.js", { |
||||
dot: true, |
||||
cwd: processor.context.exported |
||||
}, (err, files) => { |
||||
if (err) { |
||||
processor.onError(err); |
||||
return processor.done(); |
||||
} |
||||
|
||||
return processor.processTask({ |
||||
type: params.preventParallelTests ? "sequential" : "parallel", |
||||
params: { |
||||
tasks: files.map((file) => ({ |
||||
name: file, |
||||
type: "uglifyjs", |
||||
params: { |
||||
filename: file |
||||
} |
||||
})) |
||||
} |
||||
}, processor.done.bind(processor)); |
||||
}); |
||||
} |
||||
}); |
Loading…
Reference in new issue