Puneet Sabharwal
Puneet Sabharwal

Reputation: 116

webpack - How can I get the entry file name in the loaders?

I am writing a custom loader and need the ability to get the name of the entry file inside the loader. This question has been asked on webpack github twice and on file-loader githib once already.

Upvotes: 8

Views: 1215

Answers (1)

Raz Ronen
Raz Ronen

Reputation: 2628

This worked for me in dev mode:

module.exports = function loader(source) {
    const file = this._module.resource;
    ...
}

Upvotes: 1

Related Questions