Skip to content

Commit

Permalink
add in tailwind purge directives
Browse files Browse the repository at this point in the history
  • Loading branch information
ProxiBlue committed Oct 31, 2022
1 parent f3456b3 commit 9528706
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
34 changes: 34 additions & 0 deletions Observer/RegisterModuleForHyvaConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

namespace ProxiBlue\HyvaSmileAutocompleteAddToCart\Observer;

use Magento\Framework\Component\ComponentRegistrar;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;

class RegisterModuleForHyvaConfig implements ObserverInterface
{
private $componentRegistrar;

public function __construct(ComponentRegistrar $componentRegistrar)
{
$this->componentRegistrar = $componentRegistrar;
}

public function execute(Observer $event)
{
$config = $event->getData('config');
$extensions = $config->hasData('extensions') ? $config->getData('extensions') : [];

$moduleName = implode('_', array_slice(explode('\\', __CLASS__), 0, 2));

$path = $this->componentRegistrar->getPath(ComponentRegistrar::MODULE, $moduleName);

// Only use the path relative to the Magento base dir
$extensions[] = ['src' => substr($path, strlen(BP) + 1)];

$config->setData('extensions', $extensions);
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "proxi-blue/hyva-smile-autocomplete-add-to-cart",
"version": "1.1.2",
"version": "1.1.3",
"description": "Add To Cart inline in autocomplete",
"type": "magento2-module",
"require": {
Expand Down
7 changes: 7 additions & 0 deletions etc/frontend/events.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"
>
<event name="hyva_config_generate_before">
<observer name="proxiblue-smileaddtocart" instance="ProxiBlue\HyvaSmileAutocompleteAddToCart\Observer\RegisterModuleForHyvaConfig"/>
</event>
</config>
7 changes: 7 additions & 0 deletions view/frontend/tailwind/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
purge: {
content: [
'../templates/**/*.phtml',
]
}
}

0 comments on commit 9528706

Please sign in to comment.