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

Explicitly Define an Entry Point with a webpack Configuration File

InstructorAndy Van Slaars

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
~ 2 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)
~ 2 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
~ 2 years ago

Cool thanks