Created
July 23, 2019 14:02
-
-
Save pyrsmk/bd057fc3933a0b941087fb977ee0e7f5 to your computer and use it in GitHub Desktop.
Uglify task for Just
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const uglify = require('uglify-js') | |
const fs = require('fs') | |
module.exports = async options => { | |
const params = {} | |
if ('sourcemap' in options && 'filename' in options) { | |
params.sourceMap = { | |
filename: options.filename, | |
url: 'inline', | |
} | |
} | |
await new Promise((resolve, reject) => { | |
fs.readFile(options.from, 'utf8', (readError, data) => { | |
if (readError) reject(readError) | |
fs.writeFile(options.to, uglify.minify(data, params).code, writeError => { | |
if (writeError) reject(writeError) | |
resolve() | |
}) | |
}) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment