mirror of
https://github.com/flarum/core.git
synced 2025-10-21 19:56:29 +02:00
Bundle unminified JS; minify via ClosureCompilerService when in production
Falls back to a less effective minification library if ClosureCompilerService errors or is unavailable. Minification takes a while (20 seconds or so), but it only happens when assets are modified. Still, this means enabling/disabling extensions is taking far too long. Possible solutions: - Don't minify initially; set a process running in the background to do minification, and server unminified assets in the meantime. - Refactor compiler to send each JS file to CCS individually, only if that particular file has been modified. flarum/gulp has also been updated to no longer support uglification. closes #582
This commit is contained in:
@@ -198,10 +198,6 @@ class Formatter
|
||||
$configurator->enableJavaScript();
|
||||
$configurator->javascript->exportMethods = ['preview'];
|
||||
|
||||
$minifier = $configurator->javascript->setMinifier(new MinifyMinifier);
|
||||
$minifier->keepGoing = true;
|
||||
$minifier->cacheDir = $this->cacheDir;
|
||||
|
||||
return $configurator->finalize([
|
||||
'returnParser' => false,
|
||||
'returnRenderer' => false
|
||||
|
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Formatter;
|
||||
|
||||
use s9e\TextFormatter\Configurator\JavaScript\Minifier;
|
||||
use MatthiasMullie\Minify;
|
||||
|
||||
class MinifyMinifier extends Minifier
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCacheDifferentiator()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function minify($src)
|
||||
{
|
||||
$minifier = new Minify\JS($src);
|
||||
|
||||
return $minifier->minify();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user