You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/configuration/resolve.md
+55-30Lines changed: 55 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,7 @@ contributors:
6
6
- skipjack
7
7
- SpaceK33z
8
8
- pksjce
9
+
- sebastiandeutsch
9
10
---
10
11
11
12
These options change how modules are resolved. webpack provides reasonable defaults, but it is possible to change the resolving in detail.
@@ -94,27 +95,33 @@ aliasFields: ["browser"]
94
95
95
96
`array`
96
97
97
-
Default: `["package.json"]`
98
+
The JSON files to use for descriptions. Default:
98
99
99
-
The JSON files to use for descriptions.
100
+
```js
101
+
descriptionFiles: ["package.json"]
102
+
```
100
103
101
104
102
105
## `resolve.enforceExtension`
103
106
104
-
`bool`
107
+
`boolean`
105
108
106
-
Default: `false`
109
+
If `true`, it will not allow extension-less files. So by default `require('./foo')` works if `./foo` has a `.js` extension, but with this enabled only `require('./foo.js')` will work. Default:
107
110
108
-
If false it will also try to use no extension from above.
111
+
```js
112
+
enforceExtension:false
113
+
```
109
114
110
115
111
116
## `resolve.enforceModuleExtension`
112
117
113
-
`bool`
118
+
`boolean`
114
119
115
-
Default:`false`
120
+
Whether to require to use an extension for modules (e.g. loaders). Default:
116
121
117
-
If false it's also try to use no module extension from above.
122
+
```js
123
+
enforceModuleExtension:false
124
+
```
118
125
119
126
120
127
## `resolve.extensions`
@@ -124,7 +131,7 @@ If false it's also try to use no module extension from above.
124
131
Automatically resolve certain extensions. This defaults to:
125
132
126
133
```js
127
-
extensions: [".js", ".json"]
134
+
extensions: [".js", ".json"]
128
135
```
129
136
130
137
which is what enables users to leave off the extension when importing:
@@ -174,9 +181,11 @@ This means that when we `import * as D3 from "d3"` this will really resolve to t
174
181
175
182
`array`
176
183
177
-
Default:`["index"]`
184
+
The filename to be used while resolving directories. Default:
178
185
179
-
The filename to be used while resolving directories.
If `true`, trying to resolve a context to its absolute path ends when a directory is found. Default:
212
221
213
-
If true, trying to resolve a context to its absolute path ends when a directory is found.
222
+
```js
223
+
resolveToContext:false
224
+
```
214
225
215
226
216
227
## `resolve.unsafeCache`
217
228
218
229
`regex``array``boolean`
219
230
220
-
Enable aggressive, but **unsafe**, caching of modules. Passing `true` will cache everything. A regular expression, or an array of regular expressions, can be used to test file paths and only cache certain modules. For example, to only cache utilities:
231
+
Enable aggressive, but **unsafe**, caching of modules. Passing `true` will cache everything. Default:
232
+
233
+
```js
234
+
unsafeCache:true
235
+
```
236
+
237
+
A regular expression, or an array of regular expressions, can be used to test file paths and only cache certain modules. For example, to only cache utilities:
221
238
222
239
```js
223
240
unsafeCache:/src\/utilities/
@@ -230,9 +247,7 @@ W> Changes to cached paths may cause failure in rare cases.
230
247
231
248
`object`
232
249
233
-
This set of options is identical to the `resolve` set above, but is used only to resolve webpack's [loader](/concepts/loaders) packages.
234
-
235
-
Default:
250
+
This set of options is identical to the `resolve` set above, but is used only to resolve webpack's [loader](/concepts/loaders) packages. Default:
236
251
237
252
```js
238
253
{
@@ -244,32 +259,42 @@ Default:
244
259
245
260
T> Note that you can use alias here and other features familiar from resolve. For example `{ txt: 'raw-loader' }` would shim `txt!templates/demo.txt` to use `raw-loader`.
246
261
247
-
## `resolveLoader.moduleTemplates`
262
+
263
+
## `resolveLoader.moduleExtensions`
248
264
249
265
`array`
250
266
251
-
That's a `resolveLoader` only property.It describes alternatives for the module name that are tried.
267
+
The extensions which are tried when resolving a module (e.g. loaders). By default this is an empty array.
If you want to use loaders without the `-loader` suffix, you can use this:
254
270
271
+
```js
272
+
moduleExtensions: ['-loaders']
273
+
```
255
274
256
-
## `resolveLoader.moduleExtensions`
257
275
258
-
`array`
276
+
## `resolve.plugins`
259
277
260
-
Example: `['-loaders']`
278
+
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).
261
279
262
-
These extensions which are tried when resolving a module.
280
+
```js
281
+
plugins: [newDirectoryNamedWebpackPlugin()]
282
+
```
263
283
264
284
265
-
## `resolve.plugins`
285
+
## `resolve.symlinks`
266
286
267
-
?> Description
287
+
`boolean`
268
288
269
-
## `resolve.symlinks`
289
+
Whether to resolvesymlinks to their symlinked location. Defaults to `true`.
270
290
271
-
?> Description
272
291
273
292
## `resolve.cachePredicate`
274
293
275
-
?> Description
294
+
`function`
295
+
296
+
A function which decides wheter a request should be cached or not. An object is passed to the function with `path` and `request` properties. Default:
0 commit comments