SlideShare a Scribd company logo
7
Most read
8
Most read
10
Most read
Introduction to Webpack 5
Anirudh Singh and Piyush Agarwal
Lack of etiquette and manners is a huge turn off.
KnolX Etiquettes
 Punctuality
Join the session 5 minutes prior to the session start time. We start on
time and conclude on time!
 Feedback
Make sure to submit a constructive feedback for all sessions as it is very
helpful for the presenter.
 Silent Mode
Keep your mobile devices in silent mode, feel free to move out of session
in case you need to attend an urgent call.
 Avoid Disturbance
Avoid unwanted chit chat during the session.
1. What is Webpack?
2. Webpack packaging application
3. Understanding the core concepts
4. Configure Webpack
5. Demo
Introduction to Webpack 5.0 Presentation
What is Webpack?
 Webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a
browser.
 When webpack processes your application, it internally builds a dependency graph from one or
more entry points and then combines every module your project needs into one or more bundles,
which are static assets to serve your content from.
02
Webpack packaging application
www.awesome-website.com
Calculate.
min.js
style.min.js
main.min.j
s
library.min.
js
Optimised
assets
 Load all types of assets in module format.
 Dynamically building the dependency
graph.
 Removing unused code in library.
 Removing duplication of code.
 Fetching modules in runtime.
How webpack works?
Index.js
cart.js
pay.js
order.js
admin.js
home.cs
s
bootstrap
.css
admin.cs
s
logo.png
admin.pn
g
webpack
.png
bundle.js
vendor.js
bundle.css
Index.html
Entry Line
Webpack Output
<script src="./bundle.js">
<script src="./vendor.js>
<link href="./bundle.css">
Webpack
03
Understanding of core concepts
 Entry
 Output
 Loaders
 Plugins
 Mode
Entry Point
 An entry point indicates which module webpack should use to begin building out its
internal dependency graph.
 Webpack will figure out which other modules and libraries that entry point depends on (directly and
indirectly).
 By default its value is ./src/index.js, but you can specify a different (or multiple) entry points by
setting an entry property in the webpack configuration.
 module.exports = {
entry: './path/to/my/entry/file.js',
}
Output
 The output property tells webpack where to emit the bundles it creates and how to name these
files. It defaults to ./dist/main.js for the main output file and to the ./dist folder for any other
generated file.
 You can configure this part of the process by specifying an output field in your configuration:
 const path = require('path');
module.exports = {
entry: './path/to/my/entry/file.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'my-first-webpack.bundle.js',
},
};
Plugins
 While loaders are used to transform certain types of modules, plugins can be leveraged to perform
a wider range of tasks like bundle optimization, asset management and injection
of environment variables.
 In order to use a plugin, you need to require() it and add it to the plugins array. Most
plugins are customizable through options. Since you can use a plugin multiple times in a configuration
for different purposes, you need to create an instance of it by calling it with the new operator.
 const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack'); //to access built-in plugins
module.exports = {
module: {
rules: [{ test: /.txt$/, use: 'raw-loader' }],
},
plugins: [new HtmlWebpackPlugin({ template: './src/index.html' })],
};
Loaders
 Out of the box, webpack only understands JavaScript and JSON files. Loaders allow webpack to
process other types of files and convert them into valid modules that can be consumed by your
application and added to the dependency graph.
 At a high level, loaders have two properties in your webpack configuration:
 The test property identifies which file or files should be transformed.
 The use property indicates which loader should be used to do the transforming.
 const path = require('path');
module.exports = {
output: {
filename: 'my-first-webpack.bundle.js',
},
module: {
rules: [{ test: /.txt$/, use: 'raw-loader' }],
},
};
Mode
 By setting the mode parameter to either development, production or none, you can
enable webpack's built-in optimizations that correspond to each environment. The default
value is production.
 module.exports = {
mode: 'production',
};
04
Configure Webpack
 Webpack.config.js
 Webpack is configuration drive and highly configurable
 Install node.js and verify npm is working fine
 Make a directory and move to the required path
 npm init –y
 npm i - - save-dev webpack-cli webpack
 code .
 Add build in package.json
Introduction to Webpack 5.0 Presentation
Introduction to Webpack 5.0 Presentation

More Related Content

Similar to Introduction to Webpack 5.0 Presentation (20)

PDF
How to Webpack your Django!
David Gibbons
 
PDF
Meetup 2022 - APIs with Quarkus.pdf
Red Hat
 
PPT
Webpack
Mallikarjuna G D
 
PDF
Introduction to React JS
Bethmi Gunasekara
 
PDF
Tomcat + other things
Aravindharamanan S
 
PDF
Spring Live Sample Chapter
Syed Shahul
 
PDF
Servlets
Abdalla Mahmoud
 
PPTX
What's New in Java 9
Richard Langlois P. Eng.
 
PDF
Full Stack React Workshop [CSSC x GDSC]
GDSC UofT Mississauga
 
PDF
Social Connections VI — IBM Connections Extensions and Themes Demystified
Claudio Procida
 
PDF
Express node js
Yashprit Singh
 
PPT
Learning spark ch07 - Running on a Cluster
phanleson
 
PPTX
Webpack
Raymond McDermott
 
PDF
Browserify
davidchubbs
 
RTF
Readme
rec2006
 
PPTX
Webpack
Anjali Chawla
 
PDF
Warsaw Frontend Meetup #1 - Webpack
Radosław Rosłaniec
 
PPTX
Dockerization of Azure Platform
nirajrules
 
PPTX
Lecture: Webpack 4
Sergei Iastrebov
 
PDF
Struts2 tutorial
izdihara
 
How to Webpack your Django!
David Gibbons
 
Meetup 2022 - APIs with Quarkus.pdf
Red Hat
 
Introduction to React JS
Bethmi Gunasekara
 
Tomcat + other things
Aravindharamanan S
 
Spring Live Sample Chapter
Syed Shahul
 
Servlets
Abdalla Mahmoud
 
What's New in Java 9
Richard Langlois P. Eng.
 
Full Stack React Workshop [CSSC x GDSC]
GDSC UofT Mississauga
 
Social Connections VI — IBM Connections Extensions and Themes Demystified
Claudio Procida
 
Express node js
Yashprit Singh
 
Learning spark ch07 - Running on a Cluster
phanleson
 
Browserify
davidchubbs
 
Readme
rec2006
 
Webpack
Anjali Chawla
 
Warsaw Frontend Meetup #1 - Webpack
Radosław Rosłaniec
 
Dockerization of Azure Platform
nirajrules
 
Lecture: Webpack 4
Sergei Iastrebov
 
Struts2 tutorial
izdihara
 

More from Knoldus Inc. (20)

PPTX
Angular Hydration Presentation (FrontEnd)
Knoldus Inc.
 
PPTX
Optimizing Test Execution: Heuristic Algorithm for Self-Healing
Knoldus Inc.
 
PPTX
Self-Healing Test Automation Framework - Healenium
Knoldus Inc.
 
PPTX
Kanban Metrics Presentation (Project Management)
Knoldus Inc.
 
PPTX
Java 17 features and implementation.pptx
Knoldus Inc.
 
PPTX
Chaos Mesh Introducing Chaos in Kubernetes
Knoldus Inc.
 
PPTX
GraalVM - A Step Ahead of JVM Presentation
Knoldus Inc.
 
PPTX
Nomad by HashiCorp Presentation (DevOps)
Knoldus Inc.
 
PPTX
Nomad by HashiCorp Presentation (DevOps)
Knoldus Inc.
 
PPTX
DAPR - Distributed Application Runtime Presentation
Knoldus Inc.
 
PPTX
Introduction to Azure Virtual WAN Presentation
Knoldus Inc.
 
PPTX
Introduction to Argo Rollouts Presentation
Knoldus Inc.
 
PPTX
Intro to Azure Container App Presentation
Knoldus Inc.
 
PPTX
Insights Unveiled Test Reporting and Observability Excellence
Knoldus Inc.
 
PPTX
Introduction to Splunk Presentation (DevOps)
Knoldus Inc.
 
PPTX
Code Camp - Data Profiling and Quality Analysis Framework
Knoldus Inc.
 
PPTX
AWS: Messaging Services in AWS Presentation
Knoldus Inc.
 
PPTX
Amazon Cognito: A Primer on Authentication and Authorization
Knoldus Inc.
 
PPTX
ZIO Http A Functional Approach to Scalable and Type-Safe Web Development
Knoldus Inc.
 
PPTX
Managing State & HTTP Requests In Ionic.
Knoldus Inc.
 
Angular Hydration Presentation (FrontEnd)
Knoldus Inc.
 
Optimizing Test Execution: Heuristic Algorithm for Self-Healing
Knoldus Inc.
 
Self-Healing Test Automation Framework - Healenium
Knoldus Inc.
 
Kanban Metrics Presentation (Project Management)
Knoldus Inc.
 
Java 17 features and implementation.pptx
Knoldus Inc.
 
Chaos Mesh Introducing Chaos in Kubernetes
Knoldus Inc.
 
GraalVM - A Step Ahead of JVM Presentation
Knoldus Inc.
 
Nomad by HashiCorp Presentation (DevOps)
Knoldus Inc.
 
Nomad by HashiCorp Presentation (DevOps)
Knoldus Inc.
 
DAPR - Distributed Application Runtime Presentation
Knoldus Inc.
 
Introduction to Azure Virtual WAN Presentation
Knoldus Inc.
 
Introduction to Argo Rollouts Presentation
Knoldus Inc.
 
Intro to Azure Container App Presentation
Knoldus Inc.
 
Insights Unveiled Test Reporting and Observability Excellence
Knoldus Inc.
 
Introduction to Splunk Presentation (DevOps)
Knoldus Inc.
 
Code Camp - Data Profiling and Quality Analysis Framework
Knoldus Inc.
 
AWS: Messaging Services in AWS Presentation
Knoldus Inc.
 
Amazon Cognito: A Primer on Authentication and Authorization
Knoldus Inc.
 
ZIO Http A Functional Approach to Scalable and Type-Safe Web Development
Knoldus Inc.
 
Managing State & HTTP Requests In Ionic.
Knoldus Inc.
 
Ad

Recently uploaded (20)

PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Complete Network Protection with Real-Time Security
L4RGINDIA
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Complete Network Protection with Real-Time Security
L4RGINDIA
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Ad

Introduction to Webpack 5.0 Presentation

  • 1. Introduction to Webpack 5 Anirudh Singh and Piyush Agarwal
  • 2. Lack of etiquette and manners is a huge turn off. KnolX Etiquettes  Punctuality Join the session 5 minutes prior to the session start time. We start on time and conclude on time!  Feedback Make sure to submit a constructive feedback for all sessions as it is very helpful for the presenter.  Silent Mode Keep your mobile devices in silent mode, feel free to move out of session in case you need to attend an urgent call.  Avoid Disturbance Avoid unwanted chit chat during the session.
  • 3. 1. What is Webpack? 2. Webpack packaging application 3. Understanding the core concepts 4. Configure Webpack 5. Demo
  • 5. What is Webpack?  Webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser.  When webpack processes your application, it internally builds a dependency graph from one or more entry points and then combines every module your project needs into one or more bundles, which are static assets to serve your content from.
  • 6. 02
  • 7. Webpack packaging application www.awesome-website.com Calculate. min.js style.min.js main.min.j s library.min. js Optimised assets  Load all types of assets in module format.  Dynamically building the dependency graph.  Removing unused code in library.  Removing duplication of code.  Fetching modules in runtime.
  • 9. 03
  • 10. Understanding of core concepts  Entry  Output  Loaders  Plugins  Mode
  • 11. Entry Point  An entry point indicates which module webpack should use to begin building out its internal dependency graph.  Webpack will figure out which other modules and libraries that entry point depends on (directly and indirectly).  By default its value is ./src/index.js, but you can specify a different (or multiple) entry points by setting an entry property in the webpack configuration.  module.exports = { entry: './path/to/my/entry/file.js', }
  • 12. Output  The output property tells webpack where to emit the bundles it creates and how to name these files. It defaults to ./dist/main.js for the main output file and to the ./dist folder for any other generated file.  You can configure this part of the process by specifying an output field in your configuration:  const path = require('path'); module.exports = { entry: './path/to/my/entry/file.js', output: { path: path.resolve(__dirname, 'dist'), filename: 'my-first-webpack.bundle.js', }, };
  • 13. Plugins  While loaders are used to transform certain types of modules, plugins can be leveraged to perform a wider range of tasks like bundle optimization, asset management and injection of environment variables.  In order to use a plugin, you need to require() it and add it to the plugins array. Most plugins are customizable through options. Since you can use a plugin multiple times in a configuration for different purposes, you need to create an instance of it by calling it with the new operator.  const HtmlWebpackPlugin = require('html-webpack-plugin'); const webpack = require('webpack'); //to access built-in plugins module.exports = { module: { rules: [{ test: /.txt$/, use: 'raw-loader' }], }, plugins: [new HtmlWebpackPlugin({ template: './src/index.html' })], };
  • 14. Loaders  Out of the box, webpack only understands JavaScript and JSON files. Loaders allow webpack to process other types of files and convert them into valid modules that can be consumed by your application and added to the dependency graph.  At a high level, loaders have two properties in your webpack configuration:  The test property identifies which file or files should be transformed.  The use property indicates which loader should be used to do the transforming.  const path = require('path'); module.exports = { output: { filename: 'my-first-webpack.bundle.js', }, module: { rules: [{ test: /.txt$/, use: 'raw-loader' }], }, };
  • 15. Mode  By setting the mode parameter to either development, production or none, you can enable webpack's built-in optimizations that correspond to each environment. The default value is production.  module.exports = { mode: 'production', };
  • 16. 04
  • 17. Configure Webpack  Webpack.config.js  Webpack is configuration drive and highly configurable  Install node.js and verify npm is working fine  Make a directory and move to the required path  npm init –y  npm i - - save-dev webpack-cli webpack  code .  Add build in package.json