docs icon indicating copy to clipboard operation
docs copied to clipboard

How to resolve loader in webpack 4?

Open pnepe6 opened this issue 7 years ago • 0 comments

Using webpack version 4.6.0

I need to resolve the path of a loader using webpack.

The loader is used like this in a node_modules dependency:

const loadedIndex = require('!!../loaders/A-loader!./index.js');

I want to override this loader A-loader with another B-loader.

Here is how my project is structured:

_ directory
  |_ node_modules
     |_ lib
        |_ loaders/A-loader.js
        |_ index.js
  |_ loaders/B-loader.js

I want to use webpack resolveLoader in order to replace the current A-loader into B-loader.

I'm not sure how to use it, i try but this doesn't work:

{
    resolveLoader {
          alias: { 
               'A-loader': 'path/to/my/directory/loaders/B-loaders.js'
          } 
    }
}

Does anybody know how can I solve this?

pnepe6 avatar Jun 08 '18 13:06 pnepe6