How to use WOW.js in Angular 2 Webpack?

I know that we need a typing file for wow.js, but I could not find it anywhere. Is there any other solution to load this external js into webpack?

+4
source share
1 answer

Follow these steps:

  • Install exports-loader
         npm i exports-loader --save-dev
    
    
  • Add this loader to webpack.config.js
         {
             test: require.resolve ('wow.js / dist / wow.js'), 
             loader: 'exports? this.WOW'
         }
    
    
  • Create a typings.d.ts file in the samples folder:
         declare module "wow.js / dist / wow.js" {
             var noTypeInfoYet: any;
             export = noTypeInfoYet;
         }
    
    
  • add import to your *.component.ts file
         import * as WOW from 'wow.js / dist / wow.js';
    
    
  • Use it well!
         ngOnInit () {
             new WOW (). init ();
         }
    
    

Of course, you can use your own webpack configuration without exports-loader , etc.

+4
source

Source: https://habr.com/ru/post/1268699/


All Articles