本文整理匯總了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'