private function addBundles(ContainerBuilder $container): void
    {
        $packages = $container->getDefinition('assets.packages');
        $context = new Reference('contao.assets.assets_context');

        if ($container->hasDefinition('assets._version_default')) {
            $version = new Reference('assets._version_default');
        } else {
            $version = new Reference('assets.empty_version_strategy');
        }

        $bundles = $container->getParameter('kernel.bundles');
        $meta = $container->getParameter('kernel.bundles_metadata');

        foreach ($bundles as $name => $class) {
            if (!is_dir($meta[$name]['path'].'/Resources/public')) {
                continue;
            }

            $packageVersion = $version;
            $packageName = $this->getBundlePackageName($name);
            $serviceId = 'assets._package_'.$packageName;
            $basePath = 'bundles/'.preg_replace('/bundle$/', '', strtolower($name));

            if (is_file($meta[$name]['path'].'/Resources/public/manifest.json')) {
                $def = new ChildDefinition('assets.json_manifest_version_strategy');
                $def->replaceArgument(0, $meta[$name]['path'].'/Resources/public/manifest.json');

                $container->setDefinition('assets._version_'.$packageName, $def);
                $packageVersion = new Reference('assets._version_'.$packageName);
            }

            $container->setDefinition($serviceId, $this->createPackageDefinition($basePath, $packageVersion, $context));
            $packages->addMethodCall('addPackage', [$packageName, new Reference($serviceId)]);
        }
    }