Reputation: 2173
this is my project structure:
.
├── node_modules
├── package.json
├── www
│ ├── css
│ ├── js
│ ├── file.js
│ ├── folder
│ ├── file2.js
│ ├── file3.js
│ ├── lib
│ ├── folder
│ ├── file4.js
│ ├── index.html
│ ├── main.js
├── webpack.config.js
I'd like to be able to do something like require('file')
, require('file2')
, require('file3')
, require('file4')
from any file in any folder of my project.
What configuration do I need to set in my webpack.config.js
? Do I maybe need to use alias
?
Thanks
Upvotes: 1
Views: 25
Reputation: 3084
alias
sounds about right, just add to your webpack.config.js
:
resolve: {
alias: {
file: '/path/to/file.js'
}
}
Upvotes: 2