mrclay/minify
Minify is a PHP asset server for combining and compressing JS/CSS with cache-friendly headers, conditional GET, long Expires, and CSS URL rewriting. Note: no longer regularly maintained and may break modern JS/CSS; use newer tooling.
mrclay/minify package remains a front-end asset optimization tool, but the 4.0.2 release introduces SCSS/SASS compatibility via scssphp 2.x, expanding its utility for Laravel applications using Laravel Mix or Vite with SCSS preprocessing. This aligns better with modern Laravel workflows where SCSS is prevalent.
scssphp 2.x improves compatibility, complex SCSS (e.g., @import with variables) may still require validation to avoid minification failures.scssphp/scssphp (v2.x), adding a minor dependency but enabling SCSS support. Verify compatibility with Laravel’s PHP version (8.1+).mix.js() or mix.sass() hooks).scssphp/scssphp@^2.0 to avoid version clashes.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| SCSS Parsing Errors | Medium | Validate SCSS input; use scssphp’s built-in error handling. |
| Performance Overhead | Medium | Benchmark SCSS minification vs. CSS; cache aggressively. |
| Cache Invalidation | Medium | Integrate with Laravel’s cache tags or event system (e.g., asset-changed). |
| Dependency Bloat | Low | scssphp is lightweight; monitor for future breaking changes. |
| Security Risks | Low | Sanitize SCSS input paths; restrict to trusted assets. |
next-sass).postCss or sass hooks to minify SCSS post-compilation.resources/scss/ files, Laravel Mix/Vite config).// app/Http/Middleware/MinifyAssets.php
public function handle(Request $request, Closure $next) {
$response = $next($request);
$contentType = $response->headers->get('Content-Type');
if (str_contains($contentType, 'css')) {
try {
$minified = minify($response->getContent());
return new Response($minified, $response->status(), $response->headers);
} catch (\Exception $e) {
// Fallback to original
return $response;
}
}
return $response;
}
postcss-cli).scssphp/scssphp@^2.0 compatibility.scssphp 2.x).@use rules) may need validation..env for SCSS-specific configs:
MINIFY_ENABLED=true
MINIFY_CACHE_DRIVER=redis
MINIFY_SCSS_ENABLED=true
MINIFY_EXCLUDE_PATTERNS=["admin/*", "*.scss.bak"]
scssphp/scssphp@^2.0: composer require scssphp/scssphp.dom and fileinfo extensions.composer require mrclay/minify.php artisan vendor:publish --provider="MrClay\Minify\MinifyServiceProvider".app/Http/Kernel.php.php artisan cache:clear).mrclay/minify and scssphp/scssphp for breaking changes.scss --check).How can I help you explore Laravel packages today?