1
0
mirror of https://github.com/flarum/core.git synced 2025-01-17 22:29:15 +01:00

Merge pull request #748 from JoshyPHP/Minifiers

Added support for new minifiers
This commit is contained in:
Toby Zerner 2016-02-07 11:37:15 +10:30
commit fb09cef540
2 changed files with 19 additions and 7 deletions

View File

@ -39,7 +39,7 @@
"tobscure/json-api": "^0.2.0",
"oyejorge/less.php": "~1.5",
"intervention/image": "^2.3.0",
"s9e/text-formatter": "^0.4.4",
"s9e/text-formatter": "^0.4.8",
"psr/http-message": "^1.0",
"zendframework/zend-diactoros": "^1.1",
"zendframework/zend-stratigility": "^1.1",

View File

@ -13,7 +13,8 @@ namespace Flarum\Asset;
use Exception;
use Illuminate\Cache\Repository;
use MatthiasMullie\Minify;
use s9e\TextFormatter\Configurator\JavaScript\Minifiers\ClosureCompilerService;
use s9e\TextFormatter\Configurator;
use s9e\TextFormatter\Configurator\JavaScript\Minifiers\FirstAvailable;
class JsCompiler extends RevisionCompiler
{
@ -82,14 +83,25 @@ class JsCompiler extends RevisionCompiler
*/
protected function minifyWithClosureCompilerService($source)
{
$minifier = new ClosureCompilerService;
// The minifier may need some classes bundled with the Configurator so we autoload it
class_exists(Configurator::class);
$minifier->compilationLevel = 'SIMPLE_OPTIMIZATIONS';
$minifier->timeout = 60;
$minifier = new FirstAvailable;
$output = $minifier->minify($source);
$remoteCache = $minifier->add('RemoteCache');
$remoteCache->url = 'http://s9e-textformatter.rhcloud.com/flarum-minifier/';
return $output;
$hostedMinifer = $minifier->add('HostedMinifier');
$hostedMinifer->url = 'http://s9e-textformatter.rhcloud.com/flarum-minifier/';
$hostedMinifer->timeout = 30;
$ccs = $minifier->add('ClosureCompilerService');
$ccs->compilationLevel = 'SIMPLE_OPTIMIZATIONS';
$ccs->timeout = 30;
$minifier->add('MatthiasMullieMinify');
return $minifier->minify($source);
}
/**