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 |
|
5 | Webpack-literate module resolution plugin for [`eslint-plugin-import`](https://www.npmjs.com/package/eslint-plugin-import).
|
6 |
|
7 | Published separately to allow pegging to a specific version in case of breaking
|
8 | changes.
|
9 |
|
10 | To use with `eslint-plugin-import`, run:
|
11 |
|
12 | ```
|
13 | npm i eslint-import-resolver-webpack -g
|
14 | ```
|
15 |
|
16 | or if you manage ESLint as a dev dependency:
|
17 |
|
18 | ```
|
19 | # inside your project's working tree
|
20 | npm install eslint-import-resolver-webpack --save-dev
|
21 | ```
|
22 |
|
23 | Will look for `webpack.config.js` as a sibling of the first ancestral `package.json`,
|
24 | or a `config` parameter may be provided with another filename/path either relative to the
|
25 | `package.json`, or a complete, absolute path.
|
26 |
|
27 | If 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 | ---
|
31 | settings:
|
32 | import/resolver: webpack # take all defaults
|
33 | ```
|
34 |
|
35 | or with explicit config file name:
|
36 |
|
37 | ```yaml
|
38 | ---
|
39 | settings:
|
40 | import/resolver:
|
41 | webpack:
|
42 | config: 'webpack.dev.config.js'
|
43 | ```
|
44 |
|
45 | or with explicit config file name:
|
46 |
|
47 | ```yaml
|
48 | ---
|
49 | settings:
|
50 | import/resolver:
|
51 | webpack:
|
52 | config: 'webpack.multiple.config.js'
|
53 | config-index: 1 # take the config at index 1
|
54 | ```
|
55 |
|
56 | or with explicit config object:
|
57 |
|
58 | ```yaml
|
59 | ---
|
60 | settings:
|
61 | import/resolver:
|
62 | webpack:
|
63 | config:
|
64 | resolve:
|
65 | extensions:
|
66 | - .js
|
67 | - .jsx
|
68 | ```
|
69 |
|
70 | If 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 | ---
|
74 | settings:
|
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)
|