diff --git a/composer.json b/composer.json index c22e14581..53dcec46d 100644 --- a/composer.json +++ b/composer.json @@ -19,14 +19,15 @@ "filp/whoops": "~2.0", "monolog/monolog": "~1.0", "gregwar/image": "~2.0", - "mrclay/minify": "~2.2", + "mrclay/minify": "~2.3", "donatj/phpuseragentparser": "~0.3", "pimple/pimple": "~3.0", "rockettheme/toolbox": "dev-develop", "maximebf/debugbar": "~1.10", "ext-mbstring": "*", "ext-openssl": "*", - "ext-curl": "*" + "ext-curl": "*", + "matthiasmullie/minify": "^1.3" }, "require-dev": { "codeception/codeception": "^2.1", diff --git a/composer.lock b/composer.lock index 475a54d4b..3ce74ddc3 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "6540fe071baeb33887ce471b77536934", - "content-hash": "69551d2afa393561987f664319d4e02b", + "hash": "0c9456acd530221ea069208234894da5", + "content-hash": "6fc33292b3e2c35218ed15063d46b9e7", "packages": [ { "name": "doctrine/cache", diff --git a/system/blueprints/config/system.yaml b/system/blueprints/config/system.yaml index e6ea38cc3..3cb2aca20 100644 --- a/system/blueprints/config/system.yaml +++ b/system/blueprints/config/system.yaml @@ -622,6 +622,17 @@ form: validate: type: bool + assets.css_minify_old: + type: toggle + label: PLUGIN_ADMIN.CSS_MINIFY_OLD + help: PLUGIN_ADMIN.CSS_MINIFY_OLD_HELP + highlight: 0 + options: + 1: PLUGIN_ADMIN.YES + 0: PLUGIN_ADMIN.NO + validate: + type: bool + assets.css_minify_windows: type: toggle label: PLUGIN_ADMIN.CSS_MINIFY_WINDOWS_OVERRIDE @@ -688,6 +699,17 @@ form: validate: type: bool + assets.js_minify_old: + type: toggle + label: PLUGIN_ADMIN.JAVASCRIPT_MINIFY_OLD + help: PLUGIN_ADMIN.JAVASCRIPT_MINIFY_OLD_HELP + highlight: 0 + options: + 1: PLUGIN_ADMIN.YES + 0: PLUGIN_ADMIN.NO + validate: + type: bool + assets.enable_asset_timestamp: type: toggle label: PLUGIN_ADMIN.ENABLED_TIMESTAMPS_ON_ASSETS diff --git a/system/config/system.yaml b/system/config/system.yaml index 0733e599a..18a357500 100644 --- a/system/config/system.yaml +++ b/system/config/system.yaml @@ -86,12 +86,14 @@ assets: # Configuration for Assets Manager ( css_pipeline_include_externals: true # Include external URLs in the pipeline by default css_pipeline_before_excludes: true # Render the pipeline before any excluded files css_minify: true # Minify the CSS during pipelining + css_minify_old: false # Use the previous Minify library for CSS (if having issues) css_minify_windows: false # Minify Override for Windows platforms. False by default due to ThreadStackSize css_rewrite: true # Rewrite any CSS relative URLs during pipelining js_pipeline: false # The JS pipeline is the unification of multiple JS resources into one file js_pipeline_include_externals: true # Include external URLs in the pipeline by default js_pipeline_before_excludes: true # Render the pipeline before any excluded files js_minify: true # Minify the JS during pipelining + js_minify_old: false # Use the previous Minify library for JS (if having issues) enable_asset_timestamp: false # Enable asset timestamps collections: jquery: system://assets/jquery/jquery-2.x.min.js diff --git a/system/src/Grav/Common/Assets.php b/system/src/Grav/Common/Assets.php index 64fd32077..7dbfdf786 100644 --- a/system/src/Grav/Common/Assets.php +++ b/system/src/Grav/Common/Assets.php @@ -5,7 +5,6 @@ use Closure; use Exception; use FilesystemIterator; use Grav\Common\Config\Config; -use Grav\Common\Grav; use RecursiveDirectoryIterator; use RecursiveIteratorIterator; use RegexIterator; @@ -84,9 +83,11 @@ class Assets // Default values for pipeline settings protected $css_minify = true; + protected $css_minify_old = false; protected $css_minify_windows = false; protected $css_rewrite = true; protected $js_minify = true; + protected $js_minify_old = false; // Arrays to hold assets that should NOT be pipelined protected $css_no_pipeline = []; @@ -159,6 +160,11 @@ class Assets $this->css_minify = $config['css_minify']; } + if (isset($config['css_minify_old'])) { + $this->css_minify_old = $config['css_minify_old']; + } + + if (isset($config['css_minify_windows'])) { $this->css_minify_windows = $config['css_minify_windows']; } @@ -172,6 +178,10 @@ class Assets $this->js_minify = $config['js_minify']; } + if (isset($config['js_minify_old'])) { + $this->js_minify_old = $config['js_minify_old']; + } + // Set collections if (isset($config['collections']) && is_array($config['collections'])) { $this->collections = $config['collections']; @@ -730,8 +740,14 @@ class Assets // Concatenate files $buffer = $this->gatherLinks($temp_css, CSS_ASSET); if ($css_minify) { - $min = new \CSSmin(); - $buffer = $min->run($buffer); + if ($this->css_minify_old) { + $min = new \CSSmin(); + $buffer = $min->run($buffer); + } else { + $minifier = new \MatthiasMullie\Minify\CSS(); + $minifier->add($buffer); + $buffer = $minifier->minify(); + } } // Write file @@ -804,7 +820,13 @@ class Assets // Concatenate files $buffer = $this->gatherLinks($temp_js, JS_ASSET); if ($this->js_minify) { - $buffer = \JSMin::minify($buffer); + if ($this->js_minify_old) { + $buffer = \JSMin::minify($buffer); + } else { + $minifier = new \MatthiasMullie\Minify\JS(); + $minifier->add($buffer); + $buffer = $minifier->minify(); + } } // Write file diff --git a/system/src/Grav/Console/Cli/CleanCommand.php b/system/src/Grav/Console/Cli/CleanCommand.php index d664942bc..1c2620814 100644 --- a/system/src/Grav/Console/Cli/CleanCommand.php +++ b/system/src/Grav/Console/Cli/CleanCommand.php @@ -91,6 +91,11 @@ class CleanCommand extends Command 'vendor/ircmaxell/password-compat/version-test.php', 'vendor/ircmaxell/password-compat/.travis.yml', 'vendor/ircmaxell/password-compat/test', + 'vendor/matthiasmullie/minify/bin', + 'vendor/matthiasmullie/minify/composer.json', + 'vendor/matthiasmullie/minify/CONTRIBUTING.md', + 'vendor/matthiasmullie/minify/data', + 'vendor/matthiasmullie/path-converter/composer.json', 'vendor/maximebf/debugbar/bower.json', 'vendor/maximebf/debugbar/composer.json', 'vendor/maximebf/debugbar/.bowerrc',