Open5
JavaScriptのminifierにTerserを使ってみる
ねらい
オンラインで利用可能なREPL
CLI
要Node.js
ドキュメント
オプション
Minify options
[...]
compress
(default{}
) — passfalse
to skip compressing entirely.
Pass an object to specify custom compress options.
mangle
(defaulttrue
) — passfalse
to skip mangling names, or pass
an object to specify mangle options (see below).
mangle.properties
(defaultfalse
) — a subcategory of the mangle option.
Pass an object to specify custom mangle property options.[...]
こちらに従って、Terser REPLの左上のペインを次のように書き換える:
try.terser.org
// edit terser options
{
compress: false,
mangle: false,
}
例
入力
input
const person = {
name: ["Bob", "Smith"],
age: 32,
bio: function () {
console.log(`${this.name[0]} ${this.name[1]} is ${this.age} years old.`);
},
introduceSelf: function () {
console.log(`Hi! I'm ${this.name[0]}.`);
},
};
JavaScript object basics - Learn web development | MDN
出力
output
const person={name:["Bob","Smith"],age:32,bio:function(){console.log(`${this.name[0]} ${this.name[1]} is ${this.age} years old.`)},introduceSelf:function(){console.log(`Hi! I'm ${this.name[0]}.`)}};
オプションの確認