Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile SCSS added through AssetCollector #1487

Open
ww-ysg opened this issue Jun 13, 2024 · 0 comments
Open

Compile SCSS added through AssetCollector #1487

ww-ysg opened this issue Jun 13, 2024 · 0 comments
Labels

Comments

@ww-ysg
Copy link

ww-ysg commented Jun 13, 2024

Compile SCSS added through AssetCollector

Is your feature request related to a problem? Please describe

In TYPO3 Version 10 the AssetCollector was introduced. It offers an easy way to include JavaScript and CSS Files. It would be great if SCSS Files included by the AssetCollector will be compiled just like SCSS Files included in TypoScript right now.

Describe the solution you'd like

With the AssetCollector the Event BeforeStylesheetsRenderingEvent was introduced, which could be used to compile the SCSS File. A possible Implementation could look like this:

public function __invoke(
        BeforeStylesheetsRenderingEvent $event,
    ): void {
        if(ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isFrontend()) {
            $assetCollector = $event->getAssetCollector();
            $stylesheets = $assetCollector->getStyleSheets();
            foreach ($stylesheets as $identifier => $stylesheet) {
                if(isset($stylesheet['source'])) {
                    if(str_contains($stylesheet['source'], 'EXT:')) {
                        $compiledFile = $this->compileService->getCompiledFile($GLOBALS['TYPO3_REQUEST'], $stylesheet['source']);
                        if($compiledFile) {
                            $assetCollector->addStyleSheet($identifier, $compiledFile);
                        }
                    }
                }
            }
        }
    }
@ww-ysg ww-ysg added the feature label Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant