12

In webpack.config.js to determine module we can use 3 different attributes:

...
module:{
    rules: [
        {
            test: ... // the first one, commonly used in most example we can found on internet
            include: ... // the second one
            resource: ... // the third one
            use: ['style-loader','css-loader'],
        },
        ...
    ],  
    ...
}

Docs are not explanatory about them:

Rule.test
Include all modules that pass test assertion. If you supply a Rule.test option, you cannot also supply a Rule.resource. See Rule.resource and Condition.test for details.

Rule.include
Include all modules matching any of these conditions. If you supply a Rule.include option, you cannot also supply a Rule.resource. See Rule.resource and Condition.include for details.

Rule.resource
A Condition matched with the resource. See details in Rule conditions.

Each of them are Condition type. Some of them are mutually exclusive. But what is the purpose of each? When we should use each?

If there will be only test everything would be clear.

Sonny D
  • 897
  • 9
  • 29

0 Answers0