在Shopware6中的模块激活过程中避免主题编译



我们正在使用一系列命令激活几个模块,如下所示:

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'

这似乎每次都在重建主题。

无论如何,我们要做最后的bin/build-storefront.sh,所以在这里浪费了很多时间。

有没有一种方法可以在不构建主题的情况下激活插件?

TLDR;您应该能够在以下命令中传递--skip-asset-build选项:

  • 插件:安装
  • 插件:卸载
  • 插件:激活
  • 插件:停用
  • 插件:更新

看看代码,它看起来很有希望:

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

然后我可以追踪到";激活";安装命令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(PluginPluginLifecycleService::STATE_SKIP_ASSET_BUILDING);
}

最新更新