@@ -135,21 +135,30 @@ protected function replace(array $matchedContent, LocalInterface $asset)
135135 $ relatedAsset = $ this ->assetRepo ->createRelated ($ matchedFileId , $ asset );
136136 $ resolvedPath = $ relatedAsset ->getFilePath ();
137137 $ importFiles = $ this ->fileSource ->getFiles ($ this ->getTheme ($ relatedAsset ), $ resolvedPath );
138- $ deployOnlyEnabled = ( bool ) $ this ->deploymentConfig -> get ( self :: CONFIG_PATH_SCD_ONLY_ENABLED_MODULES );
138+ $ deployOnlyEnabled = $ this ->getStaticDeployEnabledModulesFlag ( );
139139 /** @var $importFile \Magento\Framework\View\File */
140140 foreach ($ importFiles as $ importFile ) {
141141 $ moduleName = $ importFile ->getModule ();
142142
143- if ($ moduleName && $ deployOnlyEnabled && !$ this ->moduleManager ->isEnabled ($ moduleName )) {
144- continue ;
145- }
146-
147- if (!$ deployOnlyEnabled || ($ moduleName && $ deployOnlyEnabled && $ this ->moduleManager ->isEnabled ($ moduleName ))) {
143+ if (!$ deployOnlyEnabled ) {
148144 $ referenceString = $ isReference ? '(reference) ' : '' ;
149145 $ importsContent .= $ moduleName
150146 ? "@import $ referenceString' {$ moduleName }:: {$ resolvedPath }'; \n"
151147 : "@import $ referenceString' {$ matchedFileId }'; \n" ;
152148 }
149+
150+ if ($ deployOnlyEnabled ) {
151+ if ($ moduleName && !$ this ->moduleManager ->isEnabled ($ moduleName )) {
152+ continue ;
153+ }
154+
155+ if ($ moduleName && $ this ->moduleManager ->isEnabled ($ moduleName )) {
156+ $ referenceString = $ isReference ? '(reference) ' : '' ;
157+ $ importsContent .= $ moduleName
158+ ? "@import $ referenceString' {$ moduleName }:: {$ resolvedPath }'; \n"
159+ : "@import $ referenceString' {$ matchedFileId }'; \n" ;
160+ }
161+ }
153162 }
154163 } catch (\LogicException $ e ) {
155164 $ this ->errorHandler ->processException ($ e );
@@ -158,6 +167,16 @@ protected function replace(array $matchedContent, LocalInterface $asset)
158167 return $ importsContent ;
159168 }
160169
170+ /**
171+ * Retrieve flag deploy enabled modules
172+ *
173+ * @return bool
174+ */
175+ protected function getStaticDeployEnabledModulesFlag () : bool
176+ {
177+ return (bool ) $ this ->deploymentConfig ->get (self ::CONFIG_PATH_SCD_ONLY_ENABLED_MODULES );
178+ }
179+
161180 /**
162181 * Get theme model based on the information from asset
163182 *
0 commit comments