leafo/scssphp
leafo/scssphp is a PHP compiler for SCSS/Sass. Use it to compile .scss files to CSS in PHP apps, with support for variables, nesting, mixins, imports, and more. Handy for build pipelines, theming, or on-the-fly stylesheet generation.
node-sass).dart-sass) in speed and memory efficiency.@use, @forward, custom media queries).asset() helpers, Blade templates, and package managers (Composer).node-sass in Laravel Mix/Vite setups (though Vite prefers native ESBuild).sass plugin (Node.js-based) for modern projects.sass-loader (Node.js) or postcss-scss as fallbacks.@use, nesting, variables).dart-sass/sass for performance.@use)? If yes, this package may fail.laravel-mix/vite + sass plugin been ruled out?sass plugin).@use).@scss directives or custom helpers.sass-loader with scssphp via custom webpack config.vite-plugin-scss (Node.js) or shell out to PHP CLI.@use, nesting) that may break.dart-sass.node-sass in a non-critical module.php -r "require 'vendor/autoload.php'; $scss = new \ScssPhp\ScssPhp\Compiler(); echo $scss->compileFile('input.scss');" > output.css.composer.json:
"require": {
"leafo/scssphp": "^0.7.4"
}
scssphp (if replacing sass-loader).mix.sass('resources/scss/app.scss', 'public/css', {
implementation: require('scssphp/scssphp-compiler')
});
@use in this codebase").| Component | Compatibility Notes |
|---|---|
| PHP 8.0+ | May require ext-dom or ext-libxml; test for deprecation warnings. |
| Laravel Blade | Use @php directives or custom Blade components to embed compiled SCSS. |
| Laravel Mix | Custom webpack loader needed (see scssphp-webpack). |
| Vite | Not natively supported; use shell execution or a custom plugin. |
| SCSS Features | Test @import, variables, nesting, but not @use/@forward (likely broken). |
node-sass in development environments (low risk).scssphp).leafo/lessphp) may also be stale.dart-sass.asset() caching).opcache to speed up repeated compilations.parallel CLI tool for batch processing.vendor/ and compiled CSS.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| PHP version incompatibility | Build failures | Pin PHP version (e.g., 8.0) in Docker. |
| SCSS syntax unsupported | Broken stylesheets | Audit SCSS files; restrict to supported syntax. |
| Memory exhaustion | Compilation crashes | Increase PHP memory_limit; optimize SCSS. |
| Abandoned package | Security vulnerabilities | Fork and maintain; monitor dependencies. |
| Slow compilation | CI/CD bottlenecks | Cache compiled CSS; use parallel processing. |
$compiler->compile()).@use support").scssphp error reporting).scssphp integration repo for the team.How can I help you explore Laravel packages today?