1 | # enhanced-resolve
|
2 |
|
3 | Offers a async require.resolve function. It's highly configurable.
|
4 |
|
5 | ## Features
|
6 |
|
7 | * plugin system
|
8 | * provide a custom filesystem
|
9 | * sync and async node.js filesystems included
|
10 |
|
11 |
|
12 | ## Tests
|
13 |
|
14 | ``` javascript
|
15 | npm test
|
16 | ```
|
17 |
|
18 | [![Build Status](https://secure.travis-ci.org/webpack/enhanced-resolve.png?branch=master)](http://travis-ci.org/webpack/enhanced-resolve)
|
19 |
|
20 |
|
21 | ## Contributing
|
22 |
|
23 | Take a look at `lib/ResolveFactory.js` to understand how everything fits together. It provides a `createResolver(options)` function and these are the possible options:
|
24 |
|
25 | | Field | Default | Description |
|
26 | | ------------------------ | --------------------------- | ---------------------------------------------------------------------------------- |
|
27 | | modules | ["node_modules"] | A list of directories to resolve modules from, can be absolute path or folder name |
|
28 | | descriptionFiles | ["package.json"] | A list of description files to read from |
|
29 | | plugins | [] | A list of additional resolve plugins which should be applied |
|
30 | | mainFields | ["main"] | A list of main fields in description files |
|
31 | | aliasFields | [] | A list of alias fields in description files |
|
32 | | mainFiles | ["index"] | A list of main files in directories |
|
33 | | extensions | [".js", ".json", ".node"] | A list of extensions which should be tried for files |
|
34 | | enforceExtension | false | Enforce that a extension from extensions must be used |
|
35 | | moduleExtensions | [] | A list of module extsions which should be tried for modules |
|
36 | | enforceModuleExtension | false | Enforce that a extension from moduleExtensions must be used |
|
37 | | alias | [] | A list of module alias configurations or an object which maps key to value |
|
38 | | resolveToContext | false | Resolve to a context instead of a file |
|
39 | | unsafeCache | false | Use this cache object to unsafely cache the successful requests |
|
40 | | cachePredicate | function() { return true }; | A function which decides wheter a request should be cached or not. An object is passed to the function with `path` and `request` properties. |
|
41 | | fileSystem | | The file system which should be used |
|
42 | | resolver | undefined | A prepared Resolver to which the plugins are attached |
|
43 |
|
44 | The options are passed from the `revolve` key of your webpack configuration e.g.:
|
45 |
|
46 | ```
|
47 | resolve: {
|
48 | extensions: ['', '.js', '.jsx'],
|
49 | modules: ['src', 'node_modules'],
|
50 | plugins: [new DirectoryNamedWebpackPlugin()]
|
51 | ...
|
52 | },
|
53 | ```
|
54 |
|
55 | ## License
|
56 |
|
57 | Copyright (c) 2012-2016 Tobias Koppers
|
58 |
|
59 | MIT (http://www.opensource.org/licenses/mit-license.php)
|