This is a pretty good way to do it, I think.
- npm install jquery
- npm install browserify-shim
Put this line in your package.json:
browserify-shim" : { "./node_modules/jquery/dist/jquery.js" : "$" }
So on the server, your usual require('jquery')
will point to the node_modules spot. When you run browserify, it will set window.$
to the same code (you could also use jQuery
). Also, if you did want to shim those plugins, just add them like this:
"browserify-shim" : {
"./node_modules/jquery/dist/jquery.js" : "jQuery",
"./plugins/bs_modal.js" : {
"depends": [ "./node_modules/jquery/dist/jquery.js" ]
}
}
or, cleaner:
"browser" : {"jquery": "./node_modules/jquery/dist/jquery.js"},
"browserify-shim" : {
"jquery" : "jQuery",
"./plugins/bs_modal.js" : {
"depends": [ "jquery" ]
}
}