[BUGFIX] Fix SCSS compilation, cache handling and import resolution - #103
Open
davidk1982 wants to merge 1 commit into
Open
davidk1982 wants to merge 1 commit into
davidk1982 wants to merge 1 commit into
Conversation
- Simplify Compiler to use scssphp addVariables() with string values
instead of complex Value type conversion (SassColor, SassNumber, etc.)
- Use compileString('@import "...";') for reliable import resolution
instead of manually reading files and custom Importer classes
- Fix cache key to include cssFilePath so different outputfile targets
(e.g. theme.css vs custom-theme.css) get separate cache entries
- Move cache check before compiler setup for early return (performance)
- Add vendor directory as import path so SCSS files can use
@import "vendor-name/package-name/..." without fragile relative paths
- Add vendor path fallback in calculateContentHash for hash accuracy
- Add EXT: variable resolution in RenderPreProcessorHook to convert
EXT: prefixed TypoScript variable values to web-accessible paths
- Add absolute path comparison for includeCSS file matching
- Fix parseBooleanSetting() strict type error with nullable defaults
- Add typed properties and declare(strict_types=1)
- Remove unused ImportResolver and Importer classes
- Replace debug() with DebugUtility::debug()
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes SCSS compilation that was broken due to incompatibilities with scssphp v2 (Dart Sass).
Removes the complex Importer system in favor of a simplified, working approach using
compileString()with variable injection as SCSS source code.Changes
Compiler.php — Complete rewrite
addVariables()with Value objects.scssphp v2 requires
Valueobjects foraddVariables(), which cannot handle SCSS expressionslike
$line-height-base - .25. Injecting as SCSS source code evaluates them in context.(override
!default), external$varreferences appended after import (defensive fallback)./are auto-quoted to prevent parse errors(e.g.
/_assets/...paths from EXT: resolution would be interpreted as division).compileFile()→compileString(): Required for source-level variable injection.cssFilePathso different output targets get separate cache entries.RenderPreProcessorHook.php
declare(strict_types=1)and typed properties$GLOBALS['TYPO3_REQUEST']->getAttribute('frontend.typoscript')EXT:ext/...→/_assets/{hash}/...web paths)parseBooleanSetting()null handlingcompress=false+ path normalization)Removed (unused/broken with scssphp v2)
Classes/ImportResolver.phpClasses/Importer/ExtensionFilesystemImporter.phpClasses/Importer/FilesystemImporter.phpClasses/Importer/VariableFilesystemImporter.phpTechnical Context
scssphp v2 (Dart Sass compliant) introduced breaking changes:
addVariables()requiresValueobjects — raw strings no longer acceptedCompilerconstructor takes no parameters (no cache options)unitless - emoperations are invalidThe Importer-based approach from the original v13 code did not correctly handle
TypoScript variable expressions and produced incorrect CSS output (literal
$variablestrings in CSS).
Note on v14 compatibility
The
release/v14branch (14.0.4) has the same underlying bugs in its variable handling:ValueConverter::fromPhp()produces quoted strings for SCSS expressions$line-height-base - .25are not evaluated, output as literal stringsThe approach used in this PR (SCSS source injection + two-phase ordering) is directly
applicable to v14 as well. A separate PR for
release/v14could port this fix withminimal adaptation (mainly the
ScssViewHelperrefactoring and composer constraints).Testing
Tested with Bootstrap 4 SCSS compilation via theme extensions using:
$font-size-base * 1.875)