Skip to content
Closed
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
39 changes: 29 additions & 10 deletions src/content/configuration/resolve.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- jamesgeorge007
- snitin315
- sapenlei
- Mazen050
---

These options change how modules are resolved. Webpack provides reasonable defaults, but it is possible to change the resolving in detail. Have a look at [Module Resolution](/concepts/module-resolution) for more explanation of how the resolver works.
Expand Down Expand Up @@ -62,7 +63,7 @@
};
```

Now, instead of using relative paths when importing like so:
Now, instead of using relative paths when like so:

Check failure on line 66 in src/content/configuration/resolve.mdx

View workflow job for this annotation

GitHub Actions / Lint (ubuntu-latest, lts/*)

Delete `·`

```js
import Utility from "../../utilities/utility";
Expand Down Expand Up @@ -317,9 +318,9 @@
conditionNames: ["require", "node"],
},
};
```

Check failure on line 321 in src/content/configuration/resolve.mdx

View workflow job for this annotation

GitHub Actions / Lint (ubuntu-latest, lts/*)

Delete `⏎⏎`

importing


- `'foo'` will resolve to `'foo/index-require.js'`
- `'foo/bar'` will resolve to `'foo/bar-node.js'` as the `"node"` key comes before `"require"` key in the conditional exports object.
Expand Down Expand Up @@ -439,7 +440,7 @@
};
```

which is what enables users to leave off the extension when importing:
which is what enables users to leave off the extension when :

```js
import File from "../path/to/file";
Expand Down Expand Up @@ -549,7 +550,7 @@

`[string]`

When importing from an npm package, e.g. `import * as D3 from 'd3'`, this option will determine which fields in its `package.json` are checked. The default values will vary based upon the [`target`](/concepts/targets) specified in your webpack configuration.
When from an npm package, e.g. `import * as D3 from 'd3'`, this option will determine which fields in its `package.json` are checked. The default values will vary based upon the [`target`](/concepts/targets) specified in your webpack configuration.

Check failure on line 553 in src/content/configuration/resolve.mdx

View workflow job for this annotation

GitHub Actions / Lint (ubuntu-latest, lts/*)

Delete `·`

When the `target` property is set to `webworker`, `web`, or left unspecified:

Expand Down Expand Up @@ -642,29 +643,47 @@
},
};
```

### resolve.plugins

Check failure on line 646 in src/content/configuration/resolve.mdx

View workflow job for this annotation

GitHub Actions / Lint (ubuntu-latest, lts/*)

Insert `⏎`

[`[Plugin]`](/plugins/)
[`[Plugin | Function]`](/plugins/)

A list of additional resolve plugins which should be applied.

Each entry can be either:

- A plugin object with an `apply(resolver)` method
- Or a function plugin, which will be called with the resolver as both `this` and the first argument

A list of additional resolve plugins which should be applied. It allows plugins such as [`DirectoryNamedWebpackPlugin`](https://www.npmjs.com/package/directory-named-webpack-plugin).
It allows plugins such as [`DirectoryNamedWebpackPlugin`](https://www.npmjs.com/package/directory-named-webpack-plugin).

**webpack.config.js**

```js
module.exports = {
// ...
resolve: {
plugins: [new DirectoryNamedWebpackPlugin()],
plugins: [
// Object-style plugin
{
apply(resolver) {
// custom logic
},
},

// Function-style plugin
function (resolver) {
// `this` is also the resolver
},
],
},
};
```
```

Check failure on line 680 in src/content/configuration/resolve.mdx

View workflow job for this annotation

GitHub Actions / Lint (ubuntu-latest, lts/*)

Delete `·`

### resolve.preferAbsolute

`boolean`

<Badge text="5.13.0+" />
<h text="5.13.0+" />

Prefer absolute paths to [`resolve.roots`](#resolveroots) when resolving.

Expand Down
Loading