Skip to content

Commit d56a8d3

Browse files
committed
MAGETWO-50673: Static asset deployment is crazy slow with multiple locales
- MAGETWO-54828: Deploy static only in production mode
1 parent a681de9 commit d56a8d3

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

app/code/Magento/Deploy/Console/Command/DeployStaticContentCommand.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ class DeployStaticContentCommand extends Command
122122
*/
123123
const DEFAULT_JOBS_AMOUNT = 3;
124124

125+
/**
126+
* Force run of static deploy
127+
*/
128+
const FORCE_RUN_OPTION = 'force';
129+
125130
/** @var InputInterface */
126131
private $input;
127132

@@ -182,6 +187,12 @@ protected function configure()
182187
InputOption::VALUE_NONE,
183188
'If specified, then no files will be actually deployed.'
184189
),
190+
new InputOption(
191+
self::FORCE_RUN_OPTION,
192+
'-f',
193+
InputOption::VALUE_NONE,
194+
'If specified, then run files will be deployed in any mode.'
195+
),
185196
new InputOption(
186197
self::JAVASCRIPT_OPTION,
187198
null,
@@ -430,7 +441,7 @@ private function getDeployableEntities($entities, $includedEntities, $excludedEn
430441
*/
431442
protected function execute(InputInterface $input, OutputInterface $output)
432443
{
433-
if ($this->getAppState()->getMode() !== State::MODE_PRODUCTION) {
444+
if (!$input->getOption(self::FORCE_RUN_OPTION) && $this->getAppState()->getMode() !== State::MODE_PRODUCTION) {
434445
throw new LocalizedException(
435446
__(
436447
"Deploy static content is applicable only for production mode.\n"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ protected function deployStaticContent(
156156
OutputInterface $output
157157
) {
158158
$output->writeln('Starting deployment of static content');
159-
$cmd = $this->functionCallPath . 'setup:static-content:deploy '
159+
$cmd = $this->functionCallPath . 'setup:static-content:deploy -f '
160160
. implode(' ', $this->getUsedLocales());
161161

162162
/**

app/code/Magento/Deploy/Test/Unit/Model/FilesystemTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public function testRegenerateStatic()
148148
$usedLocales = array_unique(
149149
array_merge($storeLocales, $adminUserInterfaceLocales)
150150
);
151-
$staticContentDeployCmd = $this->cmdPrefix . 'setup:static-content:deploy '
151+
$staticContentDeployCmd = $this->cmdPrefix . 'setup:static-content:deploy -f '
152152
. implode(' ', $usedLocales);
153153
$setupDiCompileCmd = $this->cmdPrefix . 'setup:di:compile';
154154
$this->shellMock->expects($this->at(0))

dev/tools/grunt/tasks/deploy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = function (grunt) {
2020
ok('"pub/static" is empty.');
2121

2222
log('Deploying Magento application...');
23-
deploy = spawn('php', ['bin/magento', 'setup:static-content:deploy']);
23+
deploy = spawn('php', ['bin/magento', 'setup:static-content:deploy -f']);
2424

2525
deploy.stdout.on('data', function (data) {
2626
log(data);

0 commit comments

Comments
 (0)