Hey guys, I’m having issues with building the vendor js files as part of the assets for production. So I have saved all my third party js files under assets/scripts/vendor/ folder and my manifest.json configurations look like this:
When I hit “gulp” in my terminal, it throws me heaps errors and saying the third party codes are missing this and that. All I want just compile these codes into the main.js or ended up in the dist folder, just like how grunt.js does.
I feel that I’ve got the configuration wrong, so could you guys point me to the right direction please? Thanks heaps!
I think the important thing is not where the vendor files are stored but putting their paths inside the vendor property rather than inside the files property; I believe that tells the build process not to lint them, etc., which may work around the errors you’re getting–but that depends on the exact problem you’re running into.
Thanks for the reply @mmirus , it really helps! The “gulp” command runs without any issues now. However, the thrid party scripts are not included. What’s the proper way to link them with the theme? I’ve tried the wp_enqueue_script(), which looks like:
Hey @tezza-sr - to make sure, when you say they aren’t being included, did you check that their contents aren’t found in dist/scripts/main.js after you run gulp build? If things are working properly, you shouldn’t need any extra steps (but you also wouldn’t see the additional scripts being loaded in your site’s HTML, since they are being compiled into main.js).
Hi @mmirus, yep the third party codes are not being compiled in the dist/scripts/main.js , very strange. The steps should be pretty straight forward I reckon.
A path inside the files property such as scripts/main.js will be transformed to assets/scripts/main.js if your manifest’s paths.source is assets/ and the dependency’s external property is not set to true. The vendor property paths are relative to your project root. If you are using gulp, this is typically where your gulpfile.js is located.