Z
Z
z00912016-09-02 21:09:33
backbone.js
z0091, 2016-09-02 21:09:33

How to add backbone.cocktail to webpack?

I am moving a large project to webpack. We use backbone.cocktail
Written by a small loader

{ test: /backbone\.js$/, loader: "util/backbone.coctail"}

in backbone.cocktail.js
module.exports = function () {
    if (this.cacheable) this.cacheable();

    // This is an async loader
    var loaderAsyncCallback = this.async();

    var slug = 'var Backbone = require(' + JSON.stringify("backbone") + ');\n'
        + 'var Cocktail = require(' + JSON.stringify("backbone.cocktail") + ');\n'
        + 'Cocktail.patch(Backbone);\n'
        + 'module.exports = Backbone;';

    loaderAsyncCallback(null, slug);
};

For obvious reasons, after assembly, it turns out that we load ourselves
/***/ 5:
/***/ function(module, exports, __webpack_require__) {

  var Backbone = __webpack_require__(5);
  var Cocktail = __webpack_require__(148);
  Cocktail.patch(Backbone);
  module.exports = Backbone;

/***/ },

Perhaps someone has already experienced something similar?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question