How to use WOW.js in Angular 2 Webpack?

馋奶兔 提交于 2019-12-12 09:45:16

问题


I know we need typings file for wow.js but I couldn't find it anywhere. Is there any other solution for loading this external js into webpack?


回答1:


Do the following steps:

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

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



来源:https://stackoverflow.com/questions/38826223/how-to-use-wow-js-in-angular-2-webpack

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!