rollup-plugin-uglify/index.es.js

25 lines
482 B
JavaScript
Raw Permalink Normal View History

2020-08-11 17:17:47 +08:00
/**
* rollup plugin
* @author yutent<yutent.io@gmail.com>
* @date 2020/08/11 15:46:57
*/
import { minify } from 'terser'
export default function uglify(options = {}) {
// force sourcemap creation
var opt = Object.assign({ sourceMap: true }, options)
return {
name: 'uglify',
renderChunk(code) {
var result = minify(code, opt)
if (result.error) {
console.error(result.error)
throw result.error
}
return result
}
}
}