Resolve common file extensions
In the previous section, we imported our my-helper-module in our app.js as below:
import * as helperModule from './my-helper-module.js'
We can add a resolve block in our webpack.config so that webpack can resolve and automatically figure out the right file from a given path without us having to specify the extension to the file name when importing/requiring a file.
Add a resolve
property to the config object in webpack.config.js
:
And now, the we can import the helperModule.js in our app.js as below:
import * as helperModule from 'some-helper-module' // no .js extension needed to be specified here
In the next lesson, we will learn how to setup webpack to create multiple bundles for multiple entries that we may have in our application.