felixmosh
felixmosh

Reputation: 35503

Change Webpack entryPoint using Plugin

I'm writing Webpack Plugin and I need to do the same trick HotModuleReplacementPlugin does in order to inject webpack-hot-client before the app.

It changes the entry-point of the bundle to be some custom function that requires ./node_modules/webpack-hot-client/client/index.js and then loads the original entry app.

Snippet from the bundle

/***/ 0:
/***/ (function(module, exports, __webpack_require__) {

__webpack_require__("./node_modules/webpack-hot-client/client/index.js?ed7fa357-74e7-4924-8c07-8372aa814415");
module.exports = __webpack_require__("./app/index.js");

/***/ }),

I can't find the code that does that, any pointers?

Upvotes: 1

Views: 507

Answers (1)

felixmosh
felixmosh

Reputation: 35503

Ok, so I've found the answer of how HotModuleReplacementPlugin does it, apparently it not the one that responsible for that.

webpack-hot-client changes the entry point to be an Array when the first item there is the webpack-hot-client script.

Webpack creates from that array an entry that looks like I've posted.

Upvotes: 1

Related Questions