Tucker
Tucker

Reputation: 7362

node + web project + bower, browserify

I have developed a node project. It imports dependancies from package.json using require('dependancyX'). The node module works great. I'd like to have a build process that can turn the node module into a bower app. I can do this using browserify, but when I use browserify the web version of my project has all the node dependancies bundled with it. I'd prefer to have the web version only have my code, and have the other dependancies specified via the bower dependancies. I looked into browserify-shim, but I cannot figure out how to get my app built for the web recognize the bower version of the dependancies. Is what I'm trying to do going to work, and if does anyone know if a good project to model mine after?

Upvotes: 1

Views: 75

Answers (1)

Evan Shortiss
Evan Shortiss

Reputation: 1658

Are you sure you do not want to package the dependencies? It's far easier that way. In any case you can use the --external flag to tell browserify to not include certain modules when bundling e.g

browserify -e index.js -o build.js --external async

browserify -o deps.js --require async

This will build your package, but not include async. Then build a separate file with async that you can include. For bower dependencies you can do

browserify -o deps.js --require async:./bower_components/async/async.js

Upvotes: 2

Related Questions