benjaminkott / benjaminkott/bootstrap_package

Compile SCSS added through AssetCollector

Open
#1,487 0 comments 0 reactions 0 assignees View on GitHub
feature
Dominant language
PHP
Stars
355
Forks
212
Avg merge
1h 4m
Merged PRs (30d)
31

Description

# Compile SCSS added through AssetCollector

## Is your feature request related to a problem? Please describe

In TYPO3 Version 10 the [AssetCollector](https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/10.3/Feature-90522-IntroduceAssetCollector.html) 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](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Events/Events/Core/Page/BeforeStylesheetsRenderingEvent.html#BeforeStylesheetsRenderingEvent) was introduced, which could be used to compile the SCSS File. A possible Implementation could look like this:

```php
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);
}
}
}
}
}
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.