Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(config) document Rule.resolve #3199

Merged
merged 2 commits into from
Jul 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
63 changes: 63 additions & 0 deletions src/content/configuration/module.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,69 @@ module.exports = {

See [UseEntry](#useentry) for details.

## `Rule.resolve`

W> `Rule.resolve` is Available since webpack 4.36.1

Resolving can be configured on module level. See all available options on [resolve configuration page](/configuration/resolve/#resolve).
All applied resolve options get deeply merged with higher level [resolve](/configuration/resolve/#resolve).

For example, let's imagine we have an entry in `./src/index.js`, `./src/footer/default.js` and a `./src/footer/overriden.js` to demonstrate the module level resolve.

__./src/index.js__

```javascript
import footer from 'footer';
console.log(footer);
```

__./src/footer/default.js__

```javascript
export default 'default footer';
```

__./src/footer/overriden.js__

```javascript
export default 'overriden footer';
```

__webpack.js.org__

```javascript
module.exports = {
resolve: {
alias: {
'footer': './footer/default.js'
}
}
};
```

When creating a bundle with this configuration, `console.log(footer)` will output 'default footer'. Let's set `Rule.resolve` for `.js` files, and alias `footer` to `overriden.js`.

__webpack.js.org__

```javascript
module.exports = {
resolve: {
alias: {
'footer': './footer/default.js'
}
},
module: {
rules: [
alias: {
'footer': './footer/overriden.js'
}
]
}
};
```

When creating a bundle with updated configuration, `console.log(footer)` will output 'overriden footer'.


## `Condition`

Expand Down