简体   繁体   中英

How do I use only core components of the SwiperJS library in my Rails app asset pipeline?

I'm using the Swiper slider on my website. You can reference all the Swiper assets here .

Currently I'm using the bundle version of the js, which is Swiper with all the bells & whistles (ie modules). Even minified, swiper-bundle.min.js is 144kb, which is hefty. I don't need all that, only a couple of the modules would suffice.

I have a Rails 5 app with the asset pipeline, where I just say //= require blah inside of application.js .

Inside of the Swiper assets folder, I can see CJS and ESM folders which look to split up Swiper into the different modules. However, I've googled how to use Rails with CJS or ESM and there aren't many results, which leads me to believe that's not something I can use inside of my Rails app.

How can I split up the swiper-bundle.min.js within my Rails app so that I can use Swiper and only a couple select modules?

Ok it looks like this is what I was looking for:

Swiper comes with gulp builder that allows to build custom library version where you may include only required modules.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM