- Why would I use scssphp/source-span in a Laravel project instead of Laravel Mix or Webpack?
- If you’re building a Laravel app with a custom PHP-based SCSS pipeline (e.g., using scssphp instead of Node.js tools), this package provides granular source mapping for accurate error/warning reporting. Laravel Mix/Webpack users won’t need it, but it’s critical for PHP-native SCSS workflows.
- Does scssphp/source-span work with Laravel 10+?
- This package is framework-agnostic and works with any PHP project, including Laravel 10+. However, Laravel’s default asset pipeline (Mix/Webpack) doesn’t use scssphp, so integration requires manual setup. Test compatibility with your PHP version (8.1+ recommended).
- How do I install scssphp/source-span for a Laravel project?
- Run `composer require scssphp/source-span` in your Laravel project’s root. Since Laravel doesn’t natively support scssphp, you’ll need to configure a custom compiler (e.g., via Laravel’s `Asset` facade or a service provider) to use scssphp’s parser and this package for source spans.
- Can I use this package to improve SCSS error messages in Laravel Forge/Envoyer?
- Yes, but only if you’re using scssphp for compilation. Laravel Forge/Envoyer typically relies on Node.js tools, so this package won’t integrate directly. For PHP-based deployments, it’ll provide line/column accuracy in error logs, improving debugging for SCSS issues.
- What’s the difference between this and scssphp/scssphp’s built-in source mapping?
- scssphp/source-span is a standalone library focused solely on representing source code spans (file/line/column ranges) for tokens/nodes. scssphp/scssphp includes basic source mapping, but this package offers finer control for custom error reporting or tooling (e.g., IDE integration).
- Will this package slow down my Laravel SCSS compilation?
- Minimally. Source-span tracking adds negligible overhead during parsing, but the impact depends on your SCSS complexity. For most projects, the trade-off for precise error messages is worth it—especially in CI or production debugging.
- Can I use scssphp/source-span with Tailwind CSS in Laravel?
- Only if you’re compiling Tailwind’s SCSS via scssphp (not the default PostCSS setup). Tailwind’s Laravel integration relies on Node.js, so this package won’t help unless you replace the pipeline with a PHP-based alternative. Test thoroughly with your Tailwind config.
- Are there alternatives for source mapping in Laravel SCSS workflows?
- For Node.js-based Laravel pipelines (Mix/Webpack), tools like `postcss-scss` or `sass` CLI already include source maps. If you’re using scssphp, this package is the only PHP-native option. For hybrid setups, consider sticking with Node.js tools unless you have specific PHP requirements.
- How do I test if source spans are working correctly?
- Add a custom SCSS file with intentional errors (e.g., undefined variable). Check your compiler’s output—if errors include file paths and line numbers (e.g., `error: undefined variable $x in styles.scss:5:3`), the spans are working. Use `var_dump()` on parsed nodes to inspect spans programmatically.
- Is scssphp/source-span maintained? Should I use it in production?
- The package is actively maintained alongside scssphp, with updates for PHP 8.x and new features. It’s production-ready for PHP-based SCSS pipelines, but ensure you’re using a stable scssphp version. Monitor the GitHub repo for breaking changes, especially if you rely on custom error formatting.