eslint-plugin-import: webpack doesn't resolve relative to `resolve.root`
webpack lets us define a value for resolve.root
, and we can import modules relative to the root directly.
Eg:
File: webpack.config.js
resolve: {
root: path.resolve('./jsx')
}
File: /jsx/components/Button.jsx
import React, { Component } from 'react'
export default class Button extends Component {
render() {
return <button {...this.props} />
}
}
File: /jsx/Some/Deep/Nested/Dir/Component.jsx
import '../../../../components/Button'
can be written as
File: /jsx/Some/Deep/Nested/Dir/Component.jsx
import 'components/Button'
Since webpack config has defined a value for resolve.root
, I can directly import from ‘components/Button’ rather than from ‘…/…/…/…/components/Button’. This syntax is super helpful when dealing with deep nested directory structures. It would be great if the webpack resolver package could support it.
Thanks!
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 24 (8 by maintainers)
Commits related to this issue
- Suggested change to readme Took a while to hunt down why my config wasn't working and figured out that I needed to add this dependency only after reading through [#238](https://github.com/benmosher/e... — committed to dannyc5/eslint-plugin-import by deleted user 8 years ago
- Suggested change to readme (#535) Took a while to hunt down why my config wasn't working and figured out that I needed to add this dependency only after reading through [#238](https://github.com/benm... — committed to import-js/eslint-plugin-import by deleted user 8 years ago
closing for now, if you can provide a failing test case we can reopen?