mirror of
https://github.com/vrana/adminer.git
synced 2025-08-06 14:46:36 +02:00
Compile: JsShrink -> Terser
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,9 +1,6 @@
|
|||||||
[submodule "jush"]
|
[submodule "jush"]
|
||||||
path = externals/jush
|
path = externals/jush
|
||||||
url = https://github.com/vrana/jush
|
url = https://github.com/vrana/jush
|
||||||
[submodule "JsShrink"]
|
|
||||||
path = externals/JsShrink
|
|
||||||
url = https://github.com/vrana/JsShrink
|
|
||||||
[submodule "PhpShrink"]
|
[submodule "PhpShrink"]
|
||||||
path = externals/PhpShrink
|
path = externals/PhpShrink
|
||||||
url = https://github.com/vrana/PhpShrink
|
url = https://github.com/vrana/PhpShrink
|
||||||
|
13
compile.php
13
compile.php
@@ -2,7 +2,6 @@
|
|||||||
<?php
|
<?php
|
||||||
include __DIR__ . "/adminer/include/version.inc.php";
|
include __DIR__ . "/adminer/include/version.inc.php";
|
||||||
include __DIR__ . "/adminer/include/errors.inc.php";
|
include __DIR__ . "/adminer/include/errors.inc.php";
|
||||||
include __DIR__ . "/externals/JsShrink/jsShrink.php";
|
|
||||||
include __DIR__ . "/externals/PhpShrink/phpShrink.php";
|
include __DIR__ . "/externals/PhpShrink/phpShrink.php";
|
||||||
|
|
||||||
function add_apo_slashes($s) {
|
function add_apo_slashes($s) {
|
||||||
@@ -199,14 +198,12 @@ function minify_css($file) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function minify_js($file) {
|
function minify_js($file) {
|
||||||
$file = preg_replace_callback("~'use strict';~", function ($match) { // keep only the first one
|
file_put_contents("compile.js", $file);
|
||||||
static $count = 0;
|
$terser = shell_exec("terser -c --comments false compile.js"); // prints warning to stderr if terser is not available
|
||||||
$count++;
|
if ($terser) {
|
||||||
return ($count == 1 ? $match[0] : '');
|
$file = $terser;
|
||||||
}, $file);
|
|
||||||
if (function_exists('jsShrink')) {
|
|
||||||
$file = jsShrink($file);
|
|
||||||
}
|
}
|
||||||
|
unlink("compile.js");
|
||||||
return lzw_compress($file);
|
return lzw_compress($file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user