Skip to content

Commit 9d69199

Browse files
committed
test option
1 parent 5ac4347 commit 9d69199

File tree

2 files changed

+30
-22
lines changed

2 files changed

+30
-22
lines changed

ReactInjectPlugin.php

+29-21
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ protected function renderAssetHtml(\Magento\Framework\View\Asset\PropertyGroup $
6969
$removeAdobeJSJunk = boolval($this->config->getValue('react_vue_config/junk/remove'));
7070
$removeCSSjunk = boolval($this->config->getValue('react_vue_config/css/remove'));
7171

72+
if (isset($_GET['css-test'])){
73+
// Css test mode
74+
$removeCSSjunk = false;
75+
}
76+
7277
$area = $this->state->getAreaCode();
7378
$pageFilter = ['checkout', 'customer'];
7479

@@ -96,7 +101,7 @@ protected function renderAssetHtml(\Magento\Framework\View\Asset\PropertyGroup $
96101
/** @var $asset \Magento\Framework\View\Asset\AssetInterface */
97102
// Changes Start
98103
$baseURL = $this->store->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_STATIC);
99-
if ($type === 'css') {
104+
if ($removeCSSjunk && $type === 'css') {
100105
foreach ($assets as $key => $asset) {
101106
if (in_array($actionName, $this->actionFilter) && strpos($asset->getUrl(), 'styles-m')) {
102107
// http://**/static/version1642788857/frontend/Magento/luma/en_US/css/styles-m.css
@@ -231,27 +236,30 @@ protected function renderAssetHtml(\Magento\Framework\View\Asset\PropertyGroup $
231236
$this->logger->critical($e);
232237
$result .= sprintf($template, $this->urlBuilder->getUrl('', ['_direct' => 'core/index/notFound']));
233238
}
234-
// mobile CSS
235-
if ($assetOptimized && !($isProduct || $isCategory)) {
236-
$result = '<link rel="stylesheet" type="text/css" media="all" href="' . $assetOptimized . '" />' . "\n" . $result;
237-
}
238-
if ($assetOptimizedLarge) {
239-
$result = '<link rel="stylesheet" type="text/css" media="screen and (min-width: 768px)" href="' . $assetOptimizedLarge . '" />' . "\n" . $result;
240-
}
241-
if ($assetProductOptimized && $isProduct) {
242-
if (file_exists($optimisedProductCSSFileCriticalPath)) {
243-
$result = '<link rel="stylesheet" type="text/css" media="all" href="' . $optimisedProductCSSFileCriticalUrl . '" />' . "\n" . $result;
244-
$result = '<link rel="stylesheet" media="print" onload="this.onload=null;this.media=\'all\';" href="' . $assetProductOptimized . '" />' . "\n" . $result;
245-
} else {
246-
$result = '<link rel="stylesheet" type="text/css" media="all" href="' . $assetProductOptimized . '" />' . "\n" . $result;
239+
240+
if ($removeCSSjunk) {
241+
// mobile CSS
242+
if ($assetOptimized && !($isProduct || $isCategory)) {
243+
$result = '<link rel="stylesheet" type="text/css" media="all" href="' . $assetOptimized . '" />' . "\n" . $result;
247244
}
248-
}
249-
if ($assetCategoryOptimized && $isCategory) {
250-
if (file_exists($optimisedCategoryCSSFileCriticalPath)) {
251-
$result = '<link rel="stylesheet" type="text/css" media="all" href="' . $optimisedCategoryCSSFileCriticalUrl . '" />' . "\n" . $result;
252-
$result = '<link rel="stylesheet" media="print" onload="this.onload=null;this.media=\'all\';" href="' . $assetCategoryOptimized . '" />' . "\n" . $result;
253-
} else {
254-
$result = '<link rel="stylesheet" type="text/css" media="all" href="' . $assetCategoryOptimized . '" />' . "\n" . $result;
245+
if ($assetOptimizedLarge) {
246+
$result = '<link rel="stylesheet" type="text/css" media="screen and (min-width: 768px)" href="' . $assetOptimizedLarge . '" />' . "\n" . $result;
247+
}
248+
if ($assetProductOptimized && $isProduct) {
249+
if (file_exists($optimisedProductCSSFileCriticalPath)) {
250+
$result = '<link rel="stylesheet" type="text/css" media="all" href="' . $optimisedProductCSSFileCriticalUrl . '" />' . "\n" . $result;
251+
$result = '<link rel="stylesheet" media="print" onload="this.onload=null;this.media=\'all\';" href="' . $assetProductOptimized . '" />' . "\n" . $result;
252+
} else {
253+
$result = '<link rel="stylesheet" type="text/css" media="all" href="' . $assetProductOptimized . '" />' . "\n" . $result;
254+
}
255+
}
256+
if ($assetCategoryOptimized && $isCategory) {
257+
if (file_exists($optimisedCategoryCSSFileCriticalPath)) {
258+
$result = '<link rel="stylesheet" type="text/css" media="all" href="' . $optimisedCategoryCSSFileCriticalUrl . '" />' . "\n" . $result;
259+
$result = '<link rel="stylesheet" media="print" onload="this.onload=null;this.media=\'all\';" href="' . $assetCategoryOptimized . '" />' . "\n" . $result;
260+
} else {
261+
$result = '<link rel="stylesheet" type="text/css" media="all" href="' . $assetCategoryOptimized . '" />' . "\n" . $result;
262+
}
255263
}
256264
}
257265

etc/adminhtml/system.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
33
<system>
44
<tab id="react_vue" translate="label" sortOrder="999">
5-
<label>ReactJS and VueJS integration</label>
5+
<label>React-Luma integration</label>
66
</tab>
77
<section id="react_vue_config" sortOrder="10" showInWebsite="1" showInStore="1" showInDefault="1" translate="label">
88
<label>Configuration</label>

0 commit comments

Comments
 (0)