Phalcon Assets Filter 混淆 JS 代码

Phalcon Assets Filter to obfuscate JS code

有没有现成的Phalcon过滤器来混淆JS代码?我一直在谷歌搜索但没有结果。

据我所知,没有。使用 Jsmin 过滤器进行缩小,但这不会更改变量和 class 名称,因此不会混淆您的代码。

$manager
    ->collection('myscripts')
    ->setTargetPath('scripts.js')
    ->setTargetUri('/production/scripts.js')
    ->addJs('somescript.js')
    ->addJs('someotherscript.js')
    ->join(true)
    // Use the built-in Jsmin filter
    ->addFilter(new Phalcon\Assets\Filters\Jsmin());

根据文档,这个 "Deletes the characters which are insignificant to JavaScript. Comments will be removed. Tabs will be replaced with spaces. Carriage returns will be replaced with linefeeds. Most spaces and linefeeds will be removed."

---编辑---

总是可以使用 Gulp 而不是 Phalcon 的资产管道。有像 Node.js 这样的先决条件,但我发现它非常有用,因为 Gulp 有无数过滤器可用,包括混淆过滤器等等。

参见Gulp documentation