Magento2 color swatch on product compare page

Magento has swatches available for configurable product. They appears on product detail and configurable page but to show them on compare page we need to make several customization.
You need to create custom module, and I am considering that you knows basic of creating module in magento2. To proceed further add a layout file with the name as catalog_product_compare_index.xml and add below code in the file created.

<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <css src="Magento_Swatches::css/swatches.css"/>
    </head>
    <body>
        <referenceContainer name="content">
            <referenceBlock name="catalog.compare.list">
                <action method="setTemplate">
                    <argument name="template" xsi:type="string">W3solver_Compareswatch::product/compare/list.phtml</argument>
                </action>
                <block class="Magento\Framework\View\Element\RendererList" name="category.product.type.details.renderers" as="details.renderers">
                    <block class="Magento\Swatches\Block\Product\Renderer\Listing\Configurable" as="configurable" template="Magento_Swatches::product/listing/renderer.phtml" />
                </block>
            </referenceBlock>
        </referenceContainer>

    </body>
</page>

You need to add one function in your overriden list.phtml on line 63

<?php if($_item->getTypeId() == "configurable"):
        echo $block->getProductDetailsHtml($_item);
    endif;
?>