Monday 15 January 2018

Having some trouble understanding how NPM can be used with a WordPress theme

Please bear with me as I'm having difficulty articulating what I'm trying to do.I develop custom WordPress themes for a number of clients. These themes run on PHP, and Node JS is not installed on the server. I want to be able to use npm install to include certain scripts with my themes.Swiper, for example, is a native JS touch slideshow script, which offers installation via NPM. This can be done with npm install swiper, which also adds swiper to the project dependencies in package.json. Here's where I get stuck: how do I actually include that dependency at build time?I use Node JS in conjunction with Gulp in order to concatenate scripts & styles, optimize images, etc. When I run my task gulp, my theme gets compiled out of /src in to /dev.For the particular case of Swiper, I initialize it at /src/assets/scripts/swiper.init.js. Is this where I would pull in the file from node_modules, and if so, how can I do it in such a way that the module gets concatenated with the rest of my scripts?

Submitted January 15, 2018 at 09:29PM by revxx14

No comments:

Post a Comment