IntelliJ cannot resolve javascript modules called with webpack requires which are not inside the node_modules
directory
Imagine this project structure:
`- project
|- node_modules
| `- react
| `- addons.js
|- webpack.config.js
|- util
| `- tool.js
`- src
|- components
| `- uno.jsx
`- two.jsx
This is my webpack config
// webpack.config.js
var path = require('path');
module.exports = {
resolve: {
root: [
path.resolve('./src'),
path.resolve('./')
]
}
...
}
And this is how I use webpack's require
// two.js
var React = require('react/addons');
var One = require('components/one');
var Tool = require('util/tool');
// dosomething
So this works perfectly within my application, and IntelliJ looks happy with 'react/addons', how to make understand the sources for navigation, code completion and Documentation lookup for 'components/one' and 'util/tool'?
I've tried so far:
But no luck so far. Thanks.
I think this should work (or so it did in my case anyway).
In IntelliJ:
File
> Project Structure
Modules
util
and src
) and mark them as Resources
Apply
You should have code completion and documentation available now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With