1. 5
    Explicitly Define an Entry Point with a webpack Configuration File
    2m 30s

Explicitly Define an Entry Point with a webpack Configuration File

Share this video with your friends

Send Tweet

We could use webpack without any configuration and that would bundle our JavaScript, but our options will be limited. In this lesson, we'll create a webpack configuration file and we’ll explicitly define the entry point, and some output options as a starting point to build on.

Brendan Whiting
Brendan Whiting
~ 6 years ago

Why is it that in index.js we can use the import keyword (import greeting from './greet’;) but in webpack.config.js we can’t, we have to use require. I tried import path from 'path’; and `import * as path from 'path'; and both threw errors.

Andy Van Slaars
Andy Van Slaars(instructor)
~ 6 years ago

Why is it that in index.js we can use the import keyword (import greeting from './greet’;) but in webpack.config.js we can’t, we have to use require. I tried import path from 'path’; and `import * as path from 'path'; and both threw errors.

It’s because the webpack config is being run in a node process and node uses require to import modules. The code intended to run in a browser uses ES module syntax and is transformed with Babel into code that will work in a browser environment.

Brendan Whiting
Brendan Whiting
~ 6 years ago

Cool thanks

~ 3 years ago

Hello, don't you need to specified "mode" in your webpack.config.js ?

Andy Van Slaars
Andy Van Slaars(instructor)
~ 3 years ago

Hello, don't you need to specified "mode" in your webpack.config.js ?

We cover mode in the next video