Rolando
Rolando

Reputation: 62684

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.

Upvotes: 2

Views: 1224

Answers (2)

richessler
richessler

Reputation: 84

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

Upvotes: 0

Brendan Molloy
Brendan Molloy

Reputation: 2046

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.

Upvotes: 1

Related Questions