michalsnik / aos

Animate on scroll library
MIT License
26.76k stars 2.59k forks source link

Webpack 4: import AOS from 'aos'; AOS.init(); don't work. #518

Open andreimoment opened 5 years ago

andreimoment commented 5 years ago

Webpack 4: import AOS from 'aos'; AOS.init(); don't work.

How do I import AOS? How do I troubleshoot the import?

I import jquery just above it, and it works, so module compilation works properly.

// this properly imports jquery
import $ from 'jquery';
window.$ = $;

// this does nothing -- how should I troubleshoot?
import AOS from 'aos'; 
AOS.init();

I do have @import '../../node_modules/aos/dist/aos'; in my main.scss and it does hide the elements with data-aos attrubutes.

If I do import using the CDN and the script tag, everything works.

This is:

Specifications

Expected Behavior

AOS should get imported and initialize

Actual Behavior

nothing happens

Steps to Reproduce the Problem

  1. yarn add aos@next --dev
  2. in a module, add the initialization code
  3. in the html, add the data-aos attributes
  4. the tags with data-aos disappear, no js errors in console or webpack
x1nGoo commented 5 years ago

does it work now ?

andreimoment commented 4 years ago

@x1nGoo not sure I understand your comment. This is not an intermittent issue -- and I haven't seen a new release?

kevinmu17 commented 3 years ago

Old post but I'm running against the same problem. BUT, if i do webpack build it works. Seems only in dev mode that the init is not working.