Override a 3rd party plugin's js file with my frontend js file

    Hi
    
    I want to override a 3rd party plugin's js file with my frontend js file
    
    the 3rd party plugins path is the following
    
    `custom/plugins/ThirdPartyPlugin/src/Resources/app/storefront/src/third-party-plugin/third-party-plugin.plugin.js`
    
    I have created a new plugin MyPlugin and tried to import the js file 
import ThirdPartyPlugin from '../../../../../../../../ThirdPartyPlugin/src/Resources/app/storefront/src/third-party-plugin/third-party-plugin.plugin';
        
        export default class MyPlugin extends ThirdPartyPlugin 
        {
        
           -------------------
        }
    It is working now, but the problem is while deploying via the GitHub pipeline I am getting the following error
       ERROR in /plugins/MyPlugin/src/Resources/app/storefront/src/third-party-plugin/third-party-plugin.plugin.js
Module not found: Error: Can't resolve '../../../../../../../../ThirdPartyPlugin/src/Resources/app/storefront/src/third-party-plugin/third-party-plugin.plugin' in '/plugins/MyPlugin/src/Resources/app/storefront/src/third-party-plugin'

How we can replace this relative path?

Replace the path with an absolute path like the following

import ThirdPartyPlugin from '/app/custom/plugins/ThirdPartyPlugin/src/Resources/app/storefront/src/third-party-plugin/third-party-plugin.plugin';

3 Likes