本文整理汇总了TypeScript中uglify-es.minify函数的典型用法代码示例。如果您正苦于以下问题:TypeScript minify函数的具体用法?TypeScript minify怎么用?TypeScript minify使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了minify函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
parse: function (code, opts) {
let options = {
parse: {},
compress: false,
mangle: false,
output: {
ast: true,
code: false
}
};
let result = UglifyJS.minify(code, options);
if (result.error) {
let error = result.error;
error.filename = opts.filename;
error.toString = function () {
let str = error.message;
str += '\n' + opts.filename;
str += '\n' + code.split(/\r?\n/g)[result.error.line - 1];
let i = error.col, pad = '';
while (--i > -1) pad += ' ';
str += `\n` + pad + '^';
return str;
};
throw error;
}
return result.ast;
},
示例2: collect_entries
function collect_entries(name: string, bundle: Bundle): void {
for (const mod of bundle.modules) {
const minified = uglify_es.minify(mod.source, minify_opts)
if (minified.error != null) {
const {error: {message, line, col}} = minified
throw new Error(`${mod.canonical}:${line-1}:${col}: ${message}`)
} else
entries.push([name, mod.canonical, mod.is_external, minified.code.length])
}
}
示例3: add
/// <reference types="node" />
import { OutputQuoteStyle, minify } from 'uglify-es';
let code: any;
code = {
"file1.js": "function add(first, second) { return first + second; }",
"file2.js": "console.log(add(1 + 2, 3 + 4));"
};
minify(code);
code = "function add(first, second) { return first + second; }";
minify(code);
minify(code, {
output: {
quote_style: OutputQuoteStyle.AlwaysDouble
}
});
const output = minify(code, {
warnings: 'verbose',
mangle: {
properties: {
regex: /reg/
}
},
sourceMap: {
filename: 'foo.map'