Skip to content

Handle .sass files, not only .scss - #102

Open
Amoifr wants to merge 1 commit into
SymfonyCasts:mainfrom
Amoifr:fix-83-handle-sass-extension
Open

Amoifr wants to merge 1 commit into
SymfonyCasts:mainfrom
Amoifr:fix-83-handle-sass-extension

Conversation

@Amoifr

@Amoifr Amoifr commented Sep 4, 2026

Copy link
Copy Markdown

Fixes #83

The bundle already finds .sass files: SassFileHelper::resolveSassInput() never looks at extensions, and Dart Sass compiles both syntaxes. What was written for .scss alone is the translation of a Sass path into its .css counterpart, so a .sass file was served under its own name and never resolved, which is what @WossomGonzo ran into.

Three places did that translation and now share isSassFile() and stripSassExtension() on SassFileHelper:

  • SassPublicPathAssetPathResolver::resolvePublicPath()
  • SassPublicPathAssetPathResolver::getPublicFilesystemPath()
  • SassBuilder::guessCssNameFromSassFile()

The old substr($path, 0, -5) happened to be right for both extensions, since .scss and .sass are the same length. The helper cuts the extension it actually matched instead.

Five cases cover the helpers, including two guards: a .css file is not Sass, and a directory named .scss/ does not trigger the translation, which the original str_ends_with was already careful about.

The doc only ever mentioned .scss, so it now says both work.

Three reds are already there on main and are untouched by this: SassBuilderTest::testSearchForBinary wants a real sass binary, PHPStan reports five errors in Command/SassBuildCommand.php, and php-cs-fixer wants to reformat two test files.

The bundle already finds .sass files, since resolveSassInput() does not
look at extensions, and Dart Sass compiles both. Only the translation of a
Sass path into its .css counterpart was written for .scss alone, so a
.sass file was served under its own name and never resolved.

The three places that did the translation now share isSassFile() and
stripSassExtension() on SassFileHelper.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle .sass file extensions

1 participant