2
Most read
4
Most read
10
Most read
WEBPACK
WELCOME TO A SMALL SESSION ON WEBPACK
What is webpack?
webpack is a static module bundler for modern JavaScript applications. 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
ARE WE USING WEBPACK? IN XSEED
Why Webpack?
Network load
Difficult to debug
Difficult to read
Somewebsite.com (muliple file approach) Somewebsite.com (lesser files approach)
admin.
js
cart.js pay.js
order.j
s
home.
css
bootstr
ap.css
admin
.css
main.js external.js
main.
css
How drawbacks can be removed
● The development environment can follow multi file approach
● While deployment we move it to lesser files approach
THIS IS BASICALLY HOW WEBPACK WORKS
webpack
index.j
s
pay.js
cart.js
admin.
js
order.j
s
home.
css
bootstr
ap.css
admin.
css
logo.p
ng
avatar.
png
Webpack o/p
bundle.js
vendor.js
bundle.css
index.html
BASIC WEBPACK CONFIG
const path = require("path")
module.exports = {
entry: "./index.js",
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "dist")
}
}
WEBPACK LOADERS
WEBPACK cannot bundle all files natively. It needs to have loaders for different
file extensions. EX: Incase we try to load css in our project we need css loader for
it to get loaded
NOTE: The order in which we call a loader in use array should be proper
LOADER BASIC STRUCTURE
module: {
rules: [
{
test: /.css$/,
use: [
{
loader: "style-loader"
}, {
loader: "css-loader",
options: {
modules: true
}
}
]
}
]
}
ADDITIONAL CUSTOMIZATIONS
Way to further customize the output of loaders we use plugin in webpack
PLUGIN STRUCTURE:
plugins: [
new html_webpack_plugin({
template: path.resolve(__dirname, "src/index.html"),
chunks: ["index"],
inject: true,
filename: "index.html"
}),
new html_webpack_plugin({
template: path.resolve(__dirname, "src/products.html"),
chunks: ["product"],
inject: true,
filename: "products.html"
})
]
CODE SPLITTING
● Common modules can be bundled separately
● Browser cache will be used effectively
HOW TO DO CODE SPLITTING:
optimization: {
splitChunks: {
chunks: 'all'
}
}
Extract CSS from HTML using mini-css-extract-plugin
Currently style-loader injects css to html site itself because of this a single text
change in HTML will also invalidate browser cache for css
DEAD CSS CAN BE REMOVED BY: PurgeCss
Tree Shaking
PROCESS OF REMOVING UNUSED JS CODE
Q: HOW TO DO IT?
A: NOTHING JUST BUILD THE APP IN PRODUCTION MODE AND
TREESHAKING IS PERFORMED AUTOMATICALLY
THANK YOU ALL

More Related Content

PDF
Introduction of webpack 4
PDF
How to Webpack your Django!
PPTX
Improving build solutions dependency management with webpack
PDF
Creating a full stack web app with python, npm, webpack and react
PPTX
Introduction to Webpack 5.0 Presentation
PDF
Nuxtjs cheat-sheet
PPTX
An Intro into webpack
PPTX
Webpack/Parcel: What’s Happening Behind the React App?
Introduction of webpack 4
How to Webpack your Django!
Improving build solutions dependency management with webpack
Creating a full stack web app with python, npm, webpack and react
Introduction to Webpack 5.0 Presentation
Nuxtjs cheat-sheet
An Intro into webpack
Webpack/Parcel: What’s Happening Behind the React App?

Similar to WEBPACK (20)

PDF
Using RequireJS with CakePHP
PPTX
PDF
Introduction to Webpack - Ordina JWorks - CC JS & Web
PDF
Installing Webpack with React JS from Scratch.pdf
PDF
Webpack presentation
PDF
Love at first Vue
PDF
Building and deploying React applications
PDF
ITB2019 Containerizing ContentBox CMS - Gavin Pickin
PPTX
002. Working with Webpack
PDF
Warsaw Frontend Meetup #1 - Webpack
PDF
Reactjs Basics
PDF
Webpack Encore - Asset Management for the rest of us
PPTX
Custom gutenberg block development in react
PPTX
Containerizing ContentBox CMS
PDF
vitepress-en.pdf
PPT
PDF
Universal JS Web Applications with React - Luciano Mammino - Codemotion Rome ...
PDF
Universal JavaScript Web Applications with React - Luciano Mammino - Codemoti...
PDF
How Bitbucket Pipelines Loads Connect UI Assets Super-fast
Using RequireJS with CakePHP
Introduction to Webpack - Ordina JWorks - CC JS & Web
Installing Webpack with React JS from Scratch.pdf
Webpack presentation
Love at first Vue
Building and deploying React applications
ITB2019 Containerizing ContentBox CMS - Gavin Pickin
002. Working with Webpack
Warsaw Frontend Meetup #1 - Webpack
Reactjs Basics
Webpack Encore - Asset Management for the rest of us
Custom gutenberg block development in react
Containerizing ContentBox CMS
vitepress-en.pdf
Universal JS Web Applications with React - Luciano Mammino - Codemotion Rome ...
Universal JavaScript Web Applications with React - Luciano Mammino - Codemoti...
How Bitbucket Pipelines Loads Connect UI Assets Super-fast
Ad

More from home (6)

PDF
User interface & structure
PPTX
Toy compiler
POT
Multi media Data mining
POT
Data mining on Social Media
PPT
Cantata++
PPT
Ubuntu
User interface & structure
Toy compiler
Multi media Data mining
Data mining on Social Media
Cantata++
Ubuntu
Ad

Recently uploaded (20)

PDF
Computer organization and architecuture Digital Notes....pdf
PDF
First part_B-Image Processing - 1 of 2).pdf
PDF
MLpara ingenieira CIVIL, meca Y AMBIENTAL
PPTX
Measurement Uncertainty and Measurement System analysis
PPTX
CONTRACTS IN CONSTRUCTION PROJECTS: TYPES
PPT
Chapter 1 - Introduction to Manufacturing Technology_2.ppt
PDF
LOW POWER CLASS AB SI POWER AMPLIFIER FOR WIRELESS MEDICAL SENSOR NETWORK
PDF
Cryptography and Network Security-Module-I.pdf
PDF
Java Basics-Introduction and program control
PDF
Influence of Green Infrastructure on Residents’ Endorsement of the New Ecolog...
PDF
Computer System Architecture 3rd Edition-M Morris Mano.pdf
PPTX
"Array and Linked List in Data Structures with Types, Operations, Implementat...
PPTX
ASME PCC-02 TRAINING -DESKTOP-NLE5HNP.pptx
PPTX
tack Data Structure with Array and Linked List Implementation, Push and Pop O...
PDF
Unit1 - AIML Chapter 1 concept and ethics
PDF
UEFA_Carbon_Footprint_Calculator_Methology_2.0.pdf
PPTX
Chapter 2 -Technology and Enginerring Materials + Composites.pptx
PDF
Prof. Dr. KAYIHURA A. SILAS MUNYANEZA, PhD..pdf
PDF
Exploratory_Data_Analysis_Fundamentals.pdf
PPTX
wireless networks, mobile computing.pptx
Computer organization and architecuture Digital Notes....pdf
First part_B-Image Processing - 1 of 2).pdf
MLpara ingenieira CIVIL, meca Y AMBIENTAL
Measurement Uncertainty and Measurement System analysis
CONTRACTS IN CONSTRUCTION PROJECTS: TYPES
Chapter 1 - Introduction to Manufacturing Technology_2.ppt
LOW POWER CLASS AB SI POWER AMPLIFIER FOR WIRELESS MEDICAL SENSOR NETWORK
Cryptography and Network Security-Module-I.pdf
Java Basics-Introduction and program control
Influence of Green Infrastructure on Residents’ Endorsement of the New Ecolog...
Computer System Architecture 3rd Edition-M Morris Mano.pdf
"Array and Linked List in Data Structures with Types, Operations, Implementat...
ASME PCC-02 TRAINING -DESKTOP-NLE5HNP.pptx
tack Data Structure with Array and Linked List Implementation, Push and Pop O...
Unit1 - AIML Chapter 1 concept and ethics
UEFA_Carbon_Footprint_Calculator_Methology_2.0.pdf
Chapter 2 -Technology and Enginerring Materials + Composites.pptx
Prof. Dr. KAYIHURA A. SILAS MUNYANEZA, PhD..pdf
Exploratory_Data_Analysis_Fundamentals.pdf
wireless networks, mobile computing.pptx

WEBPACK

  • 1. WEBPACK WELCOME TO A SMALL SESSION ON WEBPACK
  • 2. What is webpack? webpack is a static module bundler for modern JavaScript applications. 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
  • 3. ARE WE USING WEBPACK? IN XSEED
  • 4. Why Webpack? Network load Difficult to debug Difficult to read Somewebsite.com (muliple file approach) Somewebsite.com (lesser files approach) admin. js cart.js pay.js order.j s home. css bootstr ap.css admin .css main.js external.js main. css
  • 5. How drawbacks can be removed ● The development environment can follow multi file approach ● While deployment we move it to lesser files approach THIS IS BASICALLY HOW WEBPACK WORKS
  • 7. BASIC WEBPACK CONFIG const path = require("path") module.exports = { entry: "./index.js", output: { filename: "bundle.js", path: path.resolve(__dirname, "dist") } }
  • 8. WEBPACK LOADERS WEBPACK cannot bundle all files natively. It needs to have loaders for different file extensions. EX: Incase we try to load css in our project we need css loader for it to get loaded NOTE: The order in which we call a loader in use array should be proper
  • 9. LOADER BASIC STRUCTURE module: { rules: [ { test: /.css$/, use: [ { loader: "style-loader" }, { loader: "css-loader", options: { modules: true } } ] } ] }
  • 10. ADDITIONAL CUSTOMIZATIONS Way to further customize the output of loaders we use plugin in webpack PLUGIN STRUCTURE: plugins: [ new html_webpack_plugin({ template: path.resolve(__dirname, "src/index.html"), chunks: ["index"], inject: true, filename: "index.html" }), new html_webpack_plugin({ template: path.resolve(__dirname, "src/products.html"), chunks: ["product"], inject: true, filename: "products.html" }) ]
  • 11. CODE SPLITTING ● Common modules can be bundled separately ● Browser cache will be used effectively HOW TO DO CODE SPLITTING: optimization: { splitChunks: { chunks: 'all' } }
  • 12. Extract CSS from HTML using mini-css-extract-plugin Currently style-loader injects css to html site itself because of this a single text change in HTML will also invalidate browser cache for css DEAD CSS CAN BE REMOVED BY: PurgeCss
  • 13. Tree Shaking PROCESS OF REMOVING UNUSED JS CODE Q: HOW TO DO IT? A: NOTHING JUST BUILD THE APP IN PRODUCTION MODE AND TREESHAKING IS PERFORMED AUTOMATICALLY