UNPKG

2.28 kBMarkdownView Raw
1# eslint-import-resolver-webpack
2
3[![npm](https://img.shields.io/npm/v/eslint-import-resolver-webpack.svg)](https://www.npmjs.com/package/eslint-import-resolver-webpack)
4
5Webpack-literate module resolution plugin for [`eslint-plugin-import`](https://www.npmjs.com/package/eslint-plugin-import).
6
7Published separately to allow pegging to a specific version in case of breaking
8changes.
9
10To use with `eslint-plugin-import`, run:
11
12```
13npm i eslint-import-resolver-webpack -g
14```
15
16or if you manage ESLint as a dev dependency:
17
18```
19# inside your project's working tree
20npm install eslint-import-resolver-webpack --save-dev
21```
22
23Will look for `webpack.config.js` as a sibling of the first ancestral `package.json`,
24or a `config` parameter may be provided with another filename/path either relative to the
25`package.json`, or a complete, absolute path.
26
27If multiple webpack configurations are found the first configuration containing a resolve section will be used. Optionally, the `config-index` (zero-based) setting can be used to select a specific configuration.
28
29```yaml
30---
31settings:
32 import/resolver: webpack # take all defaults
33```
34
35or with explicit config file name:
36
37```yaml
38---
39settings:
40 import/resolver:
41 webpack:
42 config: 'webpack.dev.config.js'
43```
44
45or with explicit config file name:
46
47```yaml
48---
49settings:
50 import/resolver:
51 webpack:
52 config: 'webpack.multiple.config.js'
53 config-index: 1 # take the config at index 1
54```
55
56or with explicit config object:
57
58```yaml
59---
60settings:
61 import/resolver:
62 webpack:
63 config:
64 resolve:
65 extensions:
66 - .js
67 - .jsx
68```
69
70If your config relies on [environment variables](https://webpack.js.org/guides/environment-variables/), they can be specified using the `env` parameter. If your config is a function, it will be invoked with the value assigned to `env`:
71
72```yaml
73---
74settings:
75 import/resolver:
76 webpack:
77 config: 'webpack.config.js'
78 env:
79 NODE_ENV: 'local'
80 production: true
81```
82
83## Support
84
85[Get supported eslint-import-resolver-webpack with the Tidelift Subscription](https://tidelift.com/subscription/pkg/npm-eslint-import-resolver-webpack?utm_source=npm-eslint-import-resolver-webpack&utm_medium=referral&utm_campaign=readme)