Reputation: 5164
I'd like to use Backbone with webpack in the CommonJS style, but I need to understand how to:
It seems like imports-loader
might be the answer. Do I want something like this in my configuration?
module: {
loaders: [
{
test: require.resolve('_'),
loader: 'imports?_=underscore,define=>false'
},
{
test: require.resolve('backbone'),
loader: 'imports?define=>false'
}
]
},
Also, will this make it so I don't have to do var _ = require('underscore');
before I do var Backbone = require('backbone');
everywhere?
My question might be deemed a duplicate of this, but I hope to get a little more clarification than provided in the accepted answer there.
Upvotes: 3
Views: 1344
Reputation: 36418
If you've installed backbone via npm, it should be required via CommonJS. When installed, NPM modules also automatically retrieve and install their dependencies in their own node_modules
folder, which means you don't have to worry about providing underscore to backbone.
Upvotes: 5