diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 46a0dd9..019bb8a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -28,7 +28,7 @@ jobs: - name: Install Composer dependencies env: PHP_VERSION: ${{ matrix.php-versions }} - run: composer install --no-progress --prefer-dist --optimize-autoloader $(if [ "$PHP_VERSION" == "8.0" || "$PHP_VERSION" == "8.1" ]; then echo "--ignore-platform-reqs"; fi;) + run: composer config --no-plugins allow-plugins.kylekatarnls/update-helper true && composer install --no-progress --prefer-dist --optimize-autoloader $(if [ "$PHP_VERSION" == "8.0" || "$PHP_VERSION" == "8.1" ]; then echo "--ignore-platform-reqs"; fi;) - name: Run tests with code coverage env: PHP_VERSION: ${{ matrix.php-versions }} diff --git a/README.md b/README.md index 258792f..7194a4c 100644 --- a/README.md +++ b/README.md @@ -20,12 +20,21 @@ To get the latest version, simply require the project using [Composer](https://g $ composer require htmlmin/htmlmin ``` -Once installed, you need to register the `HTMLMin\HTMLMin\HTMLMinServiceProvider` service provider in your `config/app.php`, and optionally alias our facade: +Once installed, register the service provider in your `config/app.php` ```php - 'HTMLMin' => HTMLMin\HTMLMin\Facades\HTMLMin::class, +'providers' => [ + HTMLMin\HTMLMin\HTMLMinServiceProvider::class +] ``` +If you want, a facade is available to alias + +```php +'aliases' => [ + 'HTMLMin' => HTMLMin\HTMLMin\Facades\HTMLMin::class +] +``` ## Configuration diff --git a/composer.json b/composer.json index f4c21a8..a686cac 100644 --- a/composer.json +++ b/composer.json @@ -15,12 +15,12 @@ ], "require": { "php": ">=5.5.9", - "illuminate/contracts": "5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*|5.8.*|^6.0|^7.0|^8.0|^9.0", - "illuminate/filesystem": "5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*|5.8.*|^6.0|^7.0|^8.0|^9.0", - "illuminate/http": "5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*|5.8.*|^6.0|^7.0|^8.0|^9.0", - "illuminate/routing": "5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*|5.8.*|^6.0|^7.0|^8.0|^9.0", - "illuminate/support": "5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*|5.8.*|^6.0|^7.0|^8.0|^9.0", - "illuminate/view": "5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*|5.8.*|^6.0|^7.0|^8.0|^9.0", + "illuminate/contracts": "5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*|5.8.*|^6.0|^7.0|^8.0|^9.0|^10.0", + "illuminate/filesystem": "5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*|5.8.*|^6.0|^7.0|^8.0|^9.0|^10.0", + "illuminate/http": "5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*|5.8.*|^6.0|^7.0|^8.0|^9.0|^10.0", + "illuminate/routing": "5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*|5.8.*|^6.0|^7.0|^8.0|^9.0|^10.0", + "illuminate/support": "5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*|5.8.*|^6.0|^7.0|^8.0|^9.0|^10.0", + "illuminate/view": "5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*|5.8.*|^6.0|^7.0|^8.0|^9.0|^10.0", "mrclay/minify": "^2.2|^3.0" }, "require-dev": { diff --git a/src/Compilers/MinifyCompiler.php b/src/Compilers/MinifyCompiler.php index 54a898c..c0164ba 100644 --- a/src/Compilers/MinifyCompiler.php +++ b/src/Compilers/MinifyCompiler.php @@ -49,6 +49,7 @@ class MinifyCompiler extends BladeCompiler * @param string $cachePath * @param array $ignoredPaths * @param \Illuminate\View\Compilers\BladeCompiler $previousCompiler + * @param array $customDirectives * * @return void */ @@ -57,13 +58,20 @@ public function __construct( Filesystem $files, $cachePath, $ignoredPaths = [], - $previousCompiler = null + $previousCompiler = null, + $customDirectives = [] ) { parent::__construct($files, $cachePath); $this->blade = $blade; $this->ignoredPaths = $ignoredPaths; $this->compilers[] = 'Minify'; $this->previousCompiler = $previousCompiler; + + if (count($customDirectives)) { + foreach ($customDirectives as $key => $value) { + $this->directive($key, $value); + } + } } /** diff --git a/src/HTMLMinServiceProvider.php b/src/HTMLMinServiceProvider.php index 8a78f4e..7eed413 100644 --- a/src/HTMLMinServiceProvider.php +++ b/src/HTMLMinServiceProvider.php @@ -184,7 +184,7 @@ protected function registerMinifyCompiler() $storagePath = $app->config->get('view.compiled'); $ignoredPaths = $app->config->get('htmlmin.ignore', []); - return new MinifyCompiler($blade, $files, $storagePath, $ignoredPaths, $this->previousCompiler); + return new MinifyCompiler($blade, $files, $storagePath, $ignoredPaths, $this->previousCompiler, $this->previousCompiler->getCustomDirectives()); }); $this->app->alias('htmlmin.compiler', MinifyCompiler::class);