Skip to content

Commit a94756b

Browse files
committed
MAGETWO-52660: Improve performance of static assets deployment
- fix configuration
1 parent d110610 commit a94756b

File tree

1 file changed

+38
-33
lines changed

1 file changed

+38
-33
lines changed

app/code/Magento/Deploy/Model/Deploy/LocaleDeploy.php

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -196,28 +196,6 @@ function (AlternativeSourceInterface $alternativeSource) {
196196
$this->options = $options;
197197
}
198198

199-
/**
200-
* @param string $area
201-
* @param string $themePath
202-
* @return \Magento\RequireJs\Model\FileManager
203-
*/
204-
private function getRequireJsFileManager($area, $themePath)
205-
{
206-
$design = $this->designFactory->create()->setDesignTheme($themePath, $area);
207-
$assetRepo = $this->assetRepoFactory->create(['design' => $design]);
208-
return $this->fileManagerFactory->create(
209-
[
210-
'config' => $this->requireJsConfigFactory->create(
211-
[
212-
'assetRepo' => $assetRepo,
213-
'design' => $design,
214-
]
215-
),
216-
'assetRepo' => $assetRepo,
217-
]
218-
);
219-
}
220-
221199
/**
222200
* {@inheritdoc}
223201
*/
@@ -228,10 +206,7 @@ public function deploy($area, $themePath, $locale)
228206
// emulate application locale needed for correct file path resolving
229207
$this->localeResolver->setLocale($locale);
230208

231-
$fileManager = $this->getRequireJsFileManager($area, $themePath);
232-
if (!$this->getOption(Options::DRY_RUN)) {
233-
$fileManager->createRequireJsConfigAsset();
234-
}
209+
$this->deployRequireJsConfig($area, $themePath);
235210
$this->deployAppFiles($area, $themePath, $locale);
236211
$this->deployLibFiles($area, $themePath, $locale);
237212

@@ -240,16 +215,44 @@ public function deploy($area, $themePath, $locale)
240215
$dictionaryFileName = $this->jsTranslationConfig->getDictionaryFileName();
241216
$this->deployFile($dictionaryFileName, $area, $themePath, $locale, null);
242217
}
243-
if ($this->minification->isEnabled('js') && !$this->getOption(Options::DRY_RUN)) {
244-
$fileManager->createMinResolverAsset();
245-
}
246218
}
247-
$this->bundleManager->flush();
219+
if (!$this->getOption(Options::NO_JAVASCRIPT)) {
220+
$this->bundleManager->flush();
221+
}
248222
$this->output->writeln("\nSuccessful: {$this->count} files; errors: {$this->errorCount}\n---\n");
249223

250224
return $this->errorCount ? Cli::RETURN_FAILURE : Cli::RETURN_SUCCESS;
251225
}
252226

227+
/**
228+
* @param string $area
229+
* @param string $themePath
230+
* @return void
231+
*/
232+
private function deployRequireJsConfig($area, $themePath)
233+
{
234+
if (!$this->getOption(Options::DRY_RUN) && !$this->getOption(Options::NO_JAVASCRIPT)) {
235+
$design = $this->designFactory->create()->setDesignTheme($themePath, $area);
236+
$assetRepo = $this->assetRepoFactory->create(['design' => $design]);
237+
/** @var \Magento\RequireJs\Model\FileManager $fileManager */
238+
$fileManager = $this->fileManagerFactory->create(
239+
[
240+
'config' => $this->requireJsConfigFactory->create(
241+
[
242+
'assetRepo' => $assetRepo,
243+
'design' => $design,
244+
]
245+
),
246+
'assetRepo' => $assetRepo,
247+
]
248+
);
249+
$fileManager->createRequireJsConfigAsset();
250+
if ($this->minification->isEnabled('js')) {
251+
$fileManager->createMinResolverAsset();
252+
}
253+
}
254+
}
255+
253256
/**
254257
* @param string $area
255258
* @param string $themePath
@@ -280,7 +283,7 @@ private function deployAppFiles($area, $themePath, $locale)
280283
$module,
281284
$fullPath
282285
);
283-
if ($compiledFile !== '') {
286+
if ($compiledFile !== '' && !$this->checkSkip($compiledFile)) {
284287
$this->deployFile($compiledFile, $area, $themePath, $locale, $module, $fullPath);
285288
}
286289
}
@@ -303,7 +306,7 @@ private function deployLibFiles($area, $themePath, $locale)
303306

304307
$compiledFile = $this->deployFile($filePath, $area, $themePath, $locale, null);
305308

306-
if ($compiledFile !== '') {
309+
if ($compiledFile !== '' && !$this->checkSkip($compiledFile)) {
307310
$this->deployFile($compiledFile, $area, $themePath, $locale, null);
308311
}
309312
}
@@ -359,7 +362,9 @@ private function deployFile($filePath, $area, $themePath, $locale, $module, $ful
359362
$asset->getContent();
360363
} else {
361364
$this->assetPublisher->publish($asset);
362-
$this->bundleManager->addAsset($asset);
365+
if (!$this->getOption(Options::NO_JAVASCRIPT)) {
366+
$this->bundleManager->addAsset($asset);
367+
}
363368
}
364369
$this->count++;
365370
} catch (ContentProcessorException $exception) {

0 commit comments

Comments
 (0)