What is Entry — Webpack 5

How Entry Points work and how they are used in webpack.

Before continuing the article, please refer to the below link if you have missed the introduction to webpack 5

What is entry

Entry is a property that indicates webpack which module(s) / file(s) it should use to begin building out the internal dependency graph(s) of the project / application.

Three syntax of entry

  1. Single entry
  2. Multi-main entry
  3. Object entry

Single entry

The single entry syntax points to one file path to start building the dependency graph of the project / application. It is a great choice when you are looking to quickly setup a webpack configuration for an application or tool with one entry point (i.e. a library)


entry: String

module.exports = {
entry: "./src/index.js"

Multi-main entry

The multi-main entry syntax points to multiple file paths. Its creates separate dependency graphs based on these paths and finally get combined or merged into a single file.


entry: [String]

module.exports = {
entry: [

Object entry

The object entry syntax creates separate files for each key value pair in the entry object. It allows you to customize the chunk / bundled file name (key name). This is the most scalable way of defining entry / entries in your application.

This is a popular technique used to separate concerns by environment, build target, and runtime.

Usage 1

entry: { [entryChunkName] : String }

Usage 2

entry: { [entryChunkName] : [String] }

module.exports = {
entry: {
adminApp: "./src/admin.js",
homeApp: ["./src/home_1.js", "./src/home_2.js"]

The webpack configuration file specifically to highlight entry property:


You can pass an empty object to entry when you have only entry points generated by plugins (will see more about this in detail in the upcoming articles).

module.exports = {
entry: {}

GitHub Repo Link





Software engineer