简体   繁体   中英

How to use external library not available in NPM or bower in react/webpack?

I see this library here:

http://sztanko.github.io/crosslet/

There is no bower install, there is no npm install, but I want to use it in my webpack reactjs ES6 app. How can I do this properly? If not possible with ES6, JSX is fine too.

Include the library as an external in your webpack configuration as described in the Webpack documentation .

You can then refer to it as a normal import in your code, and when it's webpacked, it creates import shims that expect to find the global.

In addition to what @BrandanMolloy said, you can also just include it as an asset (js/css) within your project and utilize the libraries. If you explore the examples within http://sztanko.github.io/crosslet/ you'll see a bunch of uses, eg

new crosslet.MapView($("#map"),config);

here https://github.com/sztanko/crosslet/blob/gh-pages/examples/happiness/index.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM