From b226ef3477407df04ce030e06d7e2917a68193ef Mon Sep 17 00:00:00 2001 From: Wilmer Arambula <42547589+terabytesoftw@users.noreply.github.com> Date: Sat, 18 Nov 2023 11:39:47 -0300 Subject: [PATCH] Fix assets. (#5) --- src/BootstrapAsset.php | 6 +++--- src/BootstrapPluginAsset.php | 6 +++--- src/PopperAsset.php | 5 +++-- tests/AssetTest.php | 4 ---- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/BootstrapAsset.php b/src/BootstrapAsset.php index addfdb9..122eef7 100644 --- a/src/BootstrapAsset.php +++ b/src/BootstrapAsset.php @@ -20,10 +20,10 @@ public function init(): void { parent::init(); - $assetBootstrap = YII_ENV === 'prod' - ? ['bootstrap.min.css', 'bootstrap.min.css.map'] : ['bootstrap.css', 'bootstrap.css.map']; + $assetBootstrap = YII_ENV === 'prod' ? ['bootstrap.min.css'] : ['bootstrap.css']; + $assetBootstrapMap = YII_ENV === 'prod' ? ['bootstrap.min.css.map'] : ['bootstrap.css.map']; $this->css = $assetBootstrap; - $this->publishOptions['only'] = $assetBootstrap; + $this->publishOptions['only'] = array_merge($assetBootstrap, $assetBootstrapMap); } } diff --git a/src/BootstrapPluginAsset.php b/src/BootstrapPluginAsset.php index ac79663..ef7e5c3 100644 --- a/src/BootstrapPluginAsset.php +++ b/src/BootstrapPluginAsset.php @@ -27,10 +27,10 @@ public function init(): void { parent::init(); - $assetBootstrapPlugin = YII_ENV === 'prod' - ? ['bootstrap.bundle.min.js', 'bootstrap.bundle.min.js.map'] : ['bootstrap.bundle.js', 'bootstrap.bundle.js.map']; + $assetBootstrapPlugin = YII_ENV === 'prod' ? ['bootstrap.bundle.min.js'] : ['bootstrap.bundle.js']; + $assetBootstrapPluginMap = YII_ENV === 'prod' ? ['bootstrap.bundle.min.js.map'] : ['bootstrap.bundle.js.map']; $this->js = $assetBootstrapPlugin; - $this->publishOptions['only'] = $assetBootstrapPlugin; + $this->publishOptions['only'] = array_merge($assetBootstrapPlugin, $assetBootstrapPluginMap); } } diff --git a/src/PopperAsset.php b/src/PopperAsset.php index 817b4b0..0adecab 100644 --- a/src/PopperAsset.php +++ b/src/PopperAsset.php @@ -20,9 +20,10 @@ public function init(): void { parent::init(); - $assetPopper = YII_ENV === 'prod' ? ['popper.min.js', 'popper.min.js.map'] : ['popper.js', 'popper.js.map']; + $assetPopper = YII_ENV === 'prod' ? ['popper.min.js'] : ['popper.js']; + $assetPopperMap = YII_ENV === 'prod' ? ['popper.min.js.map'] : ['popper.js.map']; $this->css = $assetPopper; - $this->publishOptions['only'] = $assetPopper; + $this->publishOptions['only'] = array_merge($assetPopper, $assetPopperMap); } } diff --git a/tests/AssetTest.php b/tests/AssetTest.php index 15e0ed5..0010538 100644 --- a/tests/AssetTest.php +++ b/tests/AssetTest.php @@ -42,7 +42,6 @@ public function testBootstrapAssetRegister(): void $result = $view->renderFile(__DIR__ . '/support/main.php'); $this->assertStringContainsString('bootstrap.css', $result); - $this->assertStringContainsString('bootstrap.css.map', $result); } public function testBootstrapCdnAssetSimpleDependency(): void @@ -107,9 +106,7 @@ public function testBootstrapPluginAssetRegister(): void $result = $view->renderFile(__DIR__ . '/support/main.php'); $this->assertStringContainsString('bootstrap.css', $result); - $this->assertStringContainsString('bootstrap.css.map', $result); $this->assertStringContainsString('bootstrap.bundle.js', $result); - $this->assertStringContainsString('bootstrap.bundle.js.map', $result); } public function testBootstrapPluginCdnAssetSimpleDependency(): void @@ -180,7 +177,6 @@ public function testPopperAssetRegister(): void $result = $view->renderFile(__DIR__ . '/support/main.php'); $this->assertStringContainsString('popper.js', $result); - $this->assertStringContainsString('popper.js.map', $result); } public function testPopperCdnAssetSimpleDependency(): void