0

I have a custom module called Quicklink it has its own JS files and external JS files too, I've added an external JS from a third-party CDN, but when I enable the JS minification in a Magento 2 clean installation, it turns all files into minified, not just my JS files, which causes issues with the external script.

// File path: Rafaelcg/Quicklink/view/frontend/requirejs-config.js
var config = {
    map: {
        '*': {
            quicklink: 'https://cdnjs.cloudflare.com/ajax/libs/quicklink/2.0.0/quicklink.umd.js',
            polyfillio: 'https://polyfill.io/v3/polyfill.min.js?features=IntersectionObserver'
        }
    }
};

How could I avoid the minification only in the external JS files?

1 Answer 1

0

You can add this exclude rule below in your config.xml file.

File path: Rafaelcg/Quicklink/etc/config.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
    <default>
        <dev>
            <js>
                <minify_exclude>
                    <quicklink>/libs/quicklink</quicklink>
                    <polyfill>/v3/polyfill</polyfill>
                </minify_exclude>
            </js>
        </dev>
        <quicklink>
            <general>
                <active>1</active>
            </general>
        </quicklink>
    </default>
</config>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.