Alex
Alex

Reputation: 34978

Avoid Theme Compilation during module activation in Shopware 6

We are activating a couple of modules using a series of commands like this:

php bin/console plugin:install -a 'Modulenamea'
php bin/console plugin:update 'Modulenamea'
php bin/console plugin:install -a 'Modulenameb'
php bin/console plugin:update 'Modulenameb'

this seems to rebuild the theme each time.

We do a final bin/build-storefront.sh anyways, so a lot of time is wasted here.

Is there a way to activate the plugins without building the theme?

Upvotes: 1

Views: 649

Answers (1)

augsteyer
augsteyer

Reputation: 1099

TLDR; you should be able to pass the --skip-asset-build option in these commands:

  • plugin:install
  • plugin:uninstall
  • plugin:activate
  • plugin:deactivate
  • plugin:update

Looking at the code, it looks promising:

if ($input->getOption('skip-asset-build')) {
    $context->addState(PluginLifecycleService::STATE_SKIP_ASSET_BUILDING);
}

Then I can track it to the "activate" part of your install command install -a:

public function pluginActivate(PluginPreActivateEvent $event): void
{
    if ($this->skipCompile($event->getContext()->getContext())) {
        return;
    }
    ...
    $this->themeLifecycleHandler->handleThemeInstallOrUpdate(
        $storefrontPluginConfig,
        $configurationCollection,
        $event->getContext()->getContext()
    );
...
}
...
private function skipCompile(Context $context): bool
{
   return $context->hasState(Plugin\PluginLifecycleService::STATE_SKIP_ASSET_BUILDING);
}

Upvotes: 2

Related Questions