Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 15 additions & 18 deletions content/configuration/module.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ These options determine how the [different types of modules](/concepts/modules)

`RegExp | [RegExp]`

Prevent webpack from parsing any files matching the given regular expression(s). Ignored files **should not** have calls to `import`, `require`, `define` or any other importing mechanism. This can boost build performance when ignoring large libraries...
Prevent webpack from parsing any files matching the given regular expression(s). Ignored files **should not** have calls to `import`, `require`, `define` or any other importing mechanism. This can boost build performance when ignoring large libraries.

```js
noParse: /jquery|backbone/
Expand All @@ -25,35 +25,33 @@ noParse: /jquery|backbone/
An array of [Rules](#rule) which are matched to requests when modules are created. These rules can modify how the module is created. They can apply loaders to the module, or modify the parser.


## `Rule`
## Rule

A Rule can be separated into three parts: Conditions, Results and nested Rules.
A Rule can be separated into three parts Conditions, Results and nested Rules.

### `Rule` conditions
### Rule conditions

There are two input values for the conditions:

The resource: An absolute path to the file requested. It's already resolved according the [`resolve` rules](/configuration/resolve).
1. The resource: An absolute path to the file requested. It's already resolved according the [`resolve` rules](/configuration/resolve).

The issuer: An absolute path to the file of the module which requested the resource. It's the location of the import.
2. The issuer: An absolute path to the file of the module which requested the resource. It's the location of the import.

**Example:** The `import "./style.css"` from `app.js`:

Resource is `/path/to/style.css`. Issuer is `/path/to/app.js`.
**Example:** When we `import "./style.css"` from `app.js`, the resource is `/path/to/style.css` and the issuer is `/path/to/app.js`.

In a Rule the properties [`test`](#rule-test), [`include`](#rule-include), [`exclude`](#rule-exclude) and [`resource`](#rule-resource) are matched with the resource and the property [`issuer`](#rule-issuer) is matched with the issuer.

When using multiple conditions, all conditions must match.

### `Rule` results
### Rule results

Rule results are only used when the Rule condition matches.
Rule results are used only when the Rule condition matches.

There are two output values of a Rule:

The applied loaders: An array of loaders applied to the resource. Separated in pre-, post- and normal loaders.
1. Applied loaders: An array of loaders applied to the resource.

The parser options: An object with options which should be used to create the parser for this module.
2. Parser options: An options object which should be used to create the parser for this module.

These properties affect the loaders: [`loader`](#rule-loader), [`options`](#rule-options-rule-query), [`use`](#rule-use).

Expand All @@ -64,16 +62,15 @@ The [`enforce`](#rule-enforce) property affect the loader category. Whether it's
The [`parser`](#rule-parser) property affect the parser options.


## `Rule` nested rules

With the properties [`rules`](#rule-rules) and [`oneOf`](#rule-oneof) nested rules can be specified.
## Nested rules

Nested rules are used when the Rule condition matches.
Nested rules can be specified under the properties [`rules`](#rule-rules) and [`oneOf`](#rule-oneof).

These rules are evaluated when the Rule condition matches.

## `Rule.enforce`

Either `"pre"`, `"post"` or no value.
Possible values: `"pre" | "post"`

Specifies the category of the loader. No value means normal loader.

Expand Down