Allow to define whether webpack is used or not

This commit is contained in:
Jakub Tobiasz 2022-09-19 13:22:59 +02:00
parent 3cf9f5e800
commit 4c51670eaa
No known key found for this signature in database
GPG key ID: 6434250CB3525233
7 changed files with 39 additions and 5 deletions

View file

@ -786,7 +786,7 @@ jobs:
name: Build assets
run: |
bin/console assets:install public -vvv
GULP_ENV=prod yarn build
yarn encore production
-
name: Make filesystem readonly
@ -807,10 +807,10 @@ jobs:
path: etc/build/
if-no-files-found: ignore
test-webpack-build:
test-gulp-build:
runs-on: ubuntu-latest
name: "Test Webpack build (PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}, Node ${{ matrix.node }})"
name: "Test Gulp build (PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}, Node ${{ matrix.node }})"
timeout-minutes: 25
@ -905,7 +905,7 @@ jobs:
name: Build assets
run: |
bin/console assets:install public -vvv
yarn run encore production
GULP_ENV=prod yarn build
notify-about-build-failure:
runs-on: ubuntu-latest

View file

@ -17,6 +17,7 @@ imports:
- { resource: "@SyliusTaxationBundle/Resources/config/app/config.yml" }
- { resource: "@SyliusTaxonomyBundle/Resources/config/app/config.yml" }
- { resource: "@SyliusUserBundle/Resources/config/app/config.yml" }
- { resource: "@SyliusUiBundle/Resources/config/app/config.yml" }
- { resource: "@SyliusCoreBundle/Resources/config/app/parameters.yml" }
- { resource: "@SyliusCoreBundle/Resources/config/app/sylius.yml" }

View file

@ -19,10 +19,11 @@ use Sylius\Bundle\UiBundle\Registry\TemplateBlockRegistryInterface;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
final class SyliusUiExtension extends Extension
final class SyliusUiExtension extends Extension implements PrependExtensionInterface
{
public function load(array $configs, ContainerBuilder $container): void
{
@ -73,4 +74,22 @@ final class SyliusUiExtension extends Extension
$templateBlockRegistryDefinition->setArgument(0, $blocksForEvents);
}
public function prepend(ContainerBuilder $container): void
{
if (true === $container->getParameter('sylius_ui.use_webpack')) {
$container->prependExtensionConfig('framework', [
'assets' => [
'packages' => [
'shop' => [
'json_manifest_path' => '%kernel.project_dir%/public/build/shop/manifest.json',
],
'admin' => [
'json_manifest_path' => '%kernel.project_dir%/public/build/admin/manifest.json',
],
]
]
]);
}
}
}

View file

@ -1,5 +1,10 @@
imports:
- { resource: "@SyliusUiBundle/Resources/config/app/events.yaml" }
- { resource: "@SyliusUiBundle/Resources/config/app/parameters.yaml" }
twig:
globals:
use_webpack: '%sylius_ui.use_webpack%'
sylius_grid:
templates:

View file

@ -0,0 +1,5 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
parameters:
sylius_ui.use_webpack: true

View file

@ -25,6 +25,7 @@ final class SyliusUiExtensionTest extends AbstractExtensionTestCase
public function it_configures_the_multiple_event_block_listener_service_with_events_and_blocks_data(): void
{
$this->container->setParameter('kernel.debug', true);
$this->container->setParameter('sylius_ui.use_webpack', true);
$this->load(['events' => [
'first_event' => ['blocks' => [
@ -55,6 +56,7 @@ final class SyliusUiExtensionTest extends AbstractExtensionTestCase
public function it_sorts_blocks_by_their_priority_and_uses_fifo_ordering(): void
{
$this->container->setParameter('kernel.debug', true);
$this->container->setParameter('sylius_ui.use_webpack', true);
$this->load(['events' => [
'event_name' => ['blocks' => [

View file

@ -41,6 +41,8 @@ final class Kernel extends HttpKernel
protected function configureContainer(ContainerBuilder $containerBuilder, LoaderInterface $loader): void
{
$containerBuilder->setParameter('sylius_ui.use_webpack', true);
$containerBuilder->loadFromExtension('framework', [
'secret' => 'S0ME_SECRET',
]);