Do we really need the resolve (modules: ... alias:) block though?
It's not required for the example mentioned in this blog post. resolve is used to tell webpack how to resolve our imports(modules).
Eg: If you are using import 'pages/about/About'(instead of relative paths for cleaner syntax) you need to specify modules: [path.join(__dirname, 'src'), 'node_modules'] so webpack will first look for pages folder inside src. If you don't specify modules then webpack by default will check in the node_modules and throw this error Module not found: Error: Can't resolve 'pages/about/About'.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I'm glad you liked it ❤️
It's not required for the example mentioned in this blog post. resolve is used to tell webpack how to resolve our imports(modules).
Eg: If you are using
import 'pages/about/About'
(instead of relative paths for cleaner syntax) you need to specifymodules: [path.join(__dirname, 'src'), 'node_modules']
so webpack will first look forpages
folder insidesrc
. If you don't specifymodules
then webpack by default will check in the node_modules and throw this errorModule not found: Error: Can't resolve 'pages/about/About'
.