diff --git a/app/code/Magento/Developer/etc/di.xml b/app/code/Magento/Developer/etc/di.xml
index 3e08466c6a001..8d63fd7e4004a 100644
--- a/app/code/Magento/Developer/etc/di.xml
+++ b/app/code/Magento/Developer/etc/di.xml
@@ -202,11 +202,12 @@
Magento\Framework\Css\PreProcessor\File\Collector\Aggregated
+
Magento\Framework\Css\PreProcessor\File\Collector\Library
cssSourceBaseFilesSorted
- cssSourceOverriddenBaseFiles
+ cssSourceOverriddenBaseFilesSorted
@@ -215,17 +216,31 @@
cssSourceBaseFilesFiltered
+
cssSourceBaseFiles
+
web
+
+
+ cssSourceOverriddenBaseFilesFiltered
+
+
+
+
+
+ cssSourceOverriddenBaseFiles
+
+
+
web
diff --git a/lib/internal/Magento/Framework/View/File/Collector/Decorator/ModuleEnabled.php b/lib/internal/Magento/Framework/View/File/Collector/Decorator/ModuleEnabled.php
new file mode 100644
index 0000000000000..d3ca3268cc4e4
--- /dev/null
+++ b/lib/internal/Magento/Framework/View/File/Collector/Decorator/ModuleEnabled.php
@@ -0,0 +1,64 @@
+subject = $subject;
+ $this->moduleManager = $moduleManager;
+ }
+
+ /**
+ * Retrieve files
+ *
+ * Filter out theme files that belong to inactive modules or ones explicitly configured to not produce any output
+ *
+ * @param ThemeInterface $theme
+ * @param string $filePath
+ * @return File[]
+ */
+ public function getFiles(ThemeInterface $theme, $filePath): array
+ {
+ $result = [];
+ foreach ($this->subject->getFiles($theme, $filePath) as $file) {
+ if ($this->moduleManager->isEnabled($file->getModule())) {
+ $result[] = $file;
+ }
+ }
+ return $result;
+ }
+}
diff --git a/lib/internal/Magento/Framework/View/File/Collector/Decorator/ModuleOutput.php b/lib/internal/Magento/Framework/View/File/Collector/Decorator/ModuleOutput.php
index 34f32b2f6b7b2..a622a226fb7d4 100644
--- a/lib/internal/Magento/Framework/View/File/Collector/Decorator/ModuleOutput.php
+++ b/lib/internal/Magento/Framework/View/File/Collector/Decorator/ModuleOutput.php
@@ -6,7 +6,7 @@
namespace Magento\Framework\View\File\Collector\Decorator;
-use Magento\Framework\Module\Manager;
+use Magento\Framework\Module\Manager as ModuleManager;
use Magento\Framework\View\Design\ThemeInterface;
use Magento\Framework\View\File;
use Magento\Framework\View\File\CollectorInterface;
@@ -34,11 +34,11 @@ class ModuleOutput implements CollectorInterface
* Constructor
*
* @param CollectorInterface $subject
- * @param Manager $moduleManager
+ * @param ModuleManager $moduleManager
*/
public function __construct(
CollectorInterface $subject,
- Manager $moduleManager
+ ModuleManager $moduleManager
) {
$this->subject = $subject;
$this->moduleManager = $moduleManager;
@@ -51,7 +51,7 @@ public function __construct(
*
* @param ThemeInterface $theme
* @param string $filePath
- * @return \Magento\Framework\View\File[]
+ * @return File[]
*/
public function getFiles(ThemeInterface $theme, $filePath)
{
diff --git a/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/Decorator/ModuleEnabledTest.php b/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/Decorator/ModuleEnabledTest.php
new file mode 100644
index 0000000000000..6a21e4ab162b1
--- /dev/null
+++ b/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/Decorator/ModuleEnabledTest.php
@@ -0,0 +1,69 @@
+fileSourceMock = $this->getMockForAbstractClass(CollectorInterface::class);
+ $this->moduleManagerMock = $this->createMock(ModuleManager::class);
+ $this->moduleManagerMock
+ ->expects($this->any())
+ ->method('isEnabled')
+ ->will(
+ $this->returnValueMap(
+ [
+ ['Module_Enabled', true],
+ ['Module_Disabled', false],
+ ]
+ )
+ );
+ $this->model = new ModuleEnabled(
+ $this->fileSourceMock,
+ $this->moduleManagerMock
+ );
+ }
+
+ public function testGetFiles(): void
+ {
+ $theme = $this->getMockForAbstractClass(ThemeInterface::class);
+ $fileOne = new File('1.xml', 'Module_Enabled');
+ $fileTwo = new File('2.xml', 'Module_Disabled');
+ $fileThree = new File('3.xml', 'Module_Enabled', $theme);
+ $this->fileSourceMock->expects($this->once())
+ ->method('getFiles')
+ ->with($theme, '*.xml')
+ ->willReturn([$fileOne, $fileTwo, $fileThree]);
+ $this->assertSame([$fileOne, $fileThree], $this->model->getFiles($theme, '*.xml'));
+ }
+}