It Can be achieved by this way
Vendor\Module\etc\di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Framework\View\Page\Config\Renderer">
<plugin name="Vendor_Module::DisableJsMixins" type="Vendor\Module\Plugin\View\Page\Config\Renderer" />
</type>
</config>
Vendor\Module\Plugin\View\Page\Config\Renderer.php
<?php
namespace Vendor\Module\Plugin\View\Page\Config;
use Magento\Framework\App\CacheInterface;
use Magento\Framework\View\Asset\File;
use Magento\Framework\View\Page\Config;
use Magento\Framework\View\Page\Config\Renderer as MagentoRenderer;
use Vendor\Module\Helper\Data as helper;
use Magento\Framework\View\Asset\Repository;
use Magento\Framework\View\Asset\GroupedCollection;
class Renderer
{
/**
* @var Repository
*/
private $assetRepo;
/**
* @var GroupedCollection
*/
private $pageAssets;
/**
* @var helper
*/
private $helper;
public function __construct(
helper $helper,
Repository $assetRepo,
GroupedCollection $pageAssets
) {
$this->helper = $helper;
$this->assetRepo = $assetRepo;
$this->pageAssets = $pageAssets;
}
/**
* Disable js mixins if module is disabled
*
* @param MagentoRenderer $subject
* @param array $resultGroups
*
* @return array
*/
public function beforeRenderAssets(MagentoRenderer $subject, $resultGroups = [])
{
if (!$this->helper->getStatus()) {
$file = 'Vendor_Module::js/moduledisable.js';
$asset = $this->assetRepo->createAsset($file);
$this->pageAssets->insert($file, $asset, 'requirejs/require.js');
return [$resultGroups];
}
return [$resultGroups];
}
}
Vendor/Module/view/frontend/web/js/moduledisable.js
window.vendor_module_disabled = true;
Now in your requirejs-config.js
var module_mixin_enabled = !window.vendor_module_disabled,
config;
config = {
config: {
mixins: {
'Magento_Swatches/js/swatch-renderer': {
'Vendor_Module/js/swatch-renderer-mixin': module_mixin_enabled
},
'mage/gallery/gallery': {
'Vendor_Module/js/gallery-mixin': module_mixin_enabled
}
}
}
};