- Can I use mrclay/minify to minify SCSS files in Laravel with Laravel Mix or Vite?
- Yes, since version 4.0.2, mrclay/minify supports SCSS via scssphp 2.x, allowing you to minify preprocessed SCSS assets. For Laravel Mix, integrate it as a post-CSS processor, while Vite requires a custom plugin to invoke minification after SCSS compilation.
- Is mrclay/minify still actively maintained for modern Laravel applications?
- No, the package is no longer regularly maintained. The original authors recommend using modern tools like Lighthouse for performance optimization. However, it still works for basic CSS/JS/SCSS minification if you’re using PHP 8.1+ and scssphp 2.x.
- How do I install mrclay/minify in a Laravel project?
- Run `composer require mrclay/minify` and follow the [install guide](https://github.com/mrclay/minify/blob/master/docs/Install.wiki.md). Ensure your Laravel project uses PHP 8.1+ and install scssphp/scssphp@^2.0 for SCSS support via `composer require scssphp/scssphp`.
- Will mrclay/minify break modern JavaScript or CSS syntax (e.g., ES6 modules, CSS variables)?
- Yes, it may break modern syntax due to outdated parsing logic. The package was designed for older JS/CSS and lacks support for ES6 modules, CSS Grid, or advanced CSS features. Test thoroughly or use it only for legacy assets.
- Can I use mrclay/minify for runtime minification in production, or should I pre-minify assets?
- Runtime minification introduces overhead, so pre-minifying assets (e.g., via Laravel Mix or Vite) is preferable for static deployments. Use mrclay/minify only for dynamic assets or when runtime processing is unavoidable, like theme-based SCSS.
- How do I configure mrclay/minify to work with Laravel’s asset pipeline?
- For Laravel Mix, add minification as a post-processor in your `webpack.mix.js` using hooks like `mix.sass()` or `mix.postCss()`. For Vite, create a custom plugin to invoke minification after SCSS compilation. Refer to the [cookbook](https://github.com/mrclay/minify/tree/master/docs/CookBook.wiki.md) for advanced setups.
- Does mrclay/minify support cache headers like `Expires` or `ETag` for minified assets?
- Yes, mrclay/minify serves minified assets with optimal cache headers, including `Expires` and `ETag`, to leverage browser caching. This reduces redundant requests and improves performance for returning visitors.
- What are the risks of using mrclay/minify with complex SCSS (e.g., nested imports, variables)?
- Complex SCSS may fail to minify due to scssphp limitations. Validate your SCSS files first and handle errors gracefully. For large projects, consider pre-minifying SCSS during build time to avoid runtime failures.
- Are there alternatives to mrclay/minify for Laravel that support modern JS/CSS and SCSS?
- Yes, consider Laravel Mix with `purgecss`/`terser` for static assets, or Vite with its built-in minification. For runtime minification, explore Symfony’s `HttpCache` or tools like `flysystem` for CDN integration. Avoid mrclay/minify for production-critical modern JS/CSS.
- How do I test mrclay/minify in a Laravel project before deploying to production?
- Run unit tests with `composer test` or `phpunit` after installing dev dependencies. Test SCSS minification with a subset of your assets, monitor performance, and validate cache headers using browser dev tools or `curl -I`. Simulate production traffic to check stability.