问题
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:
-
Install exports-loader
npm i exports-loader --save-dev
-
Add to
webpack.config.js
this loader{ test: require.resolve('wow.js/dist/wow.js'), loader: 'exports?this.WOW' }
-
Create
typings.d.ts
file in your typings folder:declare module "wow.js/dist/wow.js" { var noTypeInfoYet: any; export = noTypeInfoYet; }
-
add import to your
*.component.ts
fileimport * 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...
来源:https://stackoverflow.com/questions/38826223/how-to-use-wow-js-in-angular-2-webpack