jeffreyvr / tailpress

TailPress is a minimal boilerplate theme for WordPress using Tailwind CSS.
https://tailpress.io
MIT License
1.25k stars 158 forks source link

Import modules via npm import #124

Closed nikolailehbrink closed 2 years ago

nikolailehbrink commented 2 years ago

Hello, unfortunately I can not get any modules working via "import" and npm install. Here is an example for swiper.js

npm install swiper

In app.js:

// import swiper bundle with all installed modules
import swiper from "swiper/bundle";

// import styles bundle
import "swiper/css/bundle";

// initialize
const swiper = new Swiper(".swiper", {
  // Optional parameters
  direction: "vertical",
  loop: true,

  // If we need pagination
  pagination: {
    el: ".swiper-pagination",
  },

  // navigation arrows
  navigation: {
    nextEl: ".swiper-button-next",
    prevEl: ".swiper-button-prev",
  },

  // And if we need a scrollbar
  scrollbar: {
    el: ".swiper-scrollbar",
  },
});

Then in single.php:

<!-- Slider main container -->
<div class="swiper">
  <!-- Additional required wrapper -->
  <div class="swiper-wrapper">
    <!-- Slides -->
    <div class="swiper-slide">Slide 1</div>
    <div class="swiper-slide">Slide 2</div>
    <div class="swiper-slide">Slide 3</div>
    ...
  </div>
  <!-- If we need pagination -->
  <div class="swiper-pagination"></div>

  <!-- If we need navigation buttons -->
  <div class="swiper-button-prev"></div>
  <div class="swiper-button-next"></div>

  <!-- If we need scrollbar -->
  <div class="swiper-scrollbar"></div>
</div>

I also tried the almost same procedure for the aos-library but that didn't work as well. Would be nice, if you could give me an example on how to do it :)