Search code examples
node.jsnpmwebpackbrowserify

Use an NPM module directly in the browser


This might be a stupid question, or the answer is so obvious that I just couldn't find it.

Basically I want to use Redux in my very simple web app. I wanna be able to include redux like this :

<script type="text/javascript" src="js/redux.js"></script>

And just use it directly in my code like this :

var store = redux.createStore(...);

I tried webpack and browserify but I couldn't make it work. Any ideas ?


Solution

  • To import Redux via a <script> tag you have to use the UMD builds.

    According to the docs, they are present on the dist/ folder.