So, I have a js file from an extension, that i need to override
the path is : app/code/MyExtension/MyExtensionSubfolder/view/frontend/web/js/script.js
Where should i put the new js file, that will override script.js from above? And what else is necessary for this to work.
If I want to override a .phtml file from this extension, is simple. Create a new folder in
app/code/design/frontend/Venustheme/kasitoo with the name combined MyExtension_MyExtensionSubfolder and then follow the path from extension and put here the phtml and it works.
But for js file from example if I create a new js file called script.js to the path
app/code/design/frontend/Venustheme/kasitoo/MyExtension_MyExtensionSubfolder/web/js/script.js is not working.
So the question is where should I put my new js file with the modifications I made, that will overide the script.js from the extension. Because if I made the changes directly in the extension, after the first update of the extension, I will lose those changes.
Solved! Go to Solution.
Hi!
Actually the magento documentation is not explained clearly from my point of view. Someone else responded to me on another site and the solution worked. I will put it here, maybe it will help others:
Create or modify app/design/frontend/yourStore/yourTheme/requirejs-config.js
var config = { "map": { "*": { "oldScriptAliasOrPath": "newScriptAliasOrPath", "MyExtension_MyExtensionSubfolder/js/script": "js/myExtensionCustom/script", } } };
First one is a generic example and the second one is using your file as an example. Using this method means your JS file would be placed in app/design/frontend/yourStore/yourTheme/web/js/myExtensionCustom/script.js.
Hi @ralucaalbu,
Maybe this link could help: http://devdocs.magento.com/guides/v2.2/javascript-dev-guide/javascript/custom_js.html
Hi!
Actually the magento documentation is not explained clearly from my point of view. Someone else responded to me on another site and the solution worked. I will put it here, maybe it will help others:
Create or modify app/design/frontend/yourStore/yourTheme/requirejs-config.js
var config = { "map": { "*": { "oldScriptAliasOrPath": "newScriptAliasOrPath", "MyExtension_MyExtensionSubfolder/js/script": "js/myExtensionCustom/script", } } };
First one is a generic example and the second one is using your file as an example. Using this method means your JS file would be placed in app/design/frontend/yourStore/yourTheme/web/js/myExtensionCustom/script.js.