SlideShare a Scribd company logo
webpack
101
What is it's purpose?
To bundle your code
How does it work?
What are some
common code
transformations?
btw...webpack is hard
It has terrible documentation
3 main things webpack
needs to know
1. the starting point of your application
2. which transformations to make on your code
3. where it should save the new transformed
code
1. Specify an entry point
// In webpack.config.js
module.exports = {
entry: [
'./app/index.js'
]
}
2. Add a loader
// In webpack.config.js
module.exports = {
entry: [
'./app/index.js'
],
module: {
loaders: [
{test: /.js$/, exclude: /node_modules/ , loader: "babel-loader" }
]
}
}
3. Specify the output
// In webpack.config.js
module.exports = {
entry: [
'./app/index.js'
],
module: {
loaders: [
{test: /.js$/, exclude: /node_modules/ , loader: "babel-loader" }
]
},
output: {
path: __dirname + '/dist',
filename: "index_bundle.js"
}
}
Run webpack
// npm install webpack webpack-dev-server
// In package.json
{
"name": "Foo Bar" ,
"version" : "1.0.0",
"description" : "",
"main": "index.js" ,
"scripts" : {
"build": "webpack -p" ,
"start": "webpack-dev-server"
},
"author": "",
"license" : "ISC",
"dependencies" : {
"react": "^15.3.2" ,
"react-dom" : "^15.3.2"
},
"devDependencies" : {
"babel-core" : "^6.18.2" ,
"babel-loader" : "^6.2.7",
"babel-preset-react" : "^6.16.0" ,
"html-webpack-plugin" : "^2.24.1" ,
"webpack" : "^1.13.3" ,
"webpack-dev-server" : "^1.16.2"
}
}
How do we reference
the bundle from HTML?
/app
- components
- containers
- config
- utils
index.js
index.html
/dist
index.html
index_bundle.js
package.json
webpack.config.js
.gitignore
html-webpack-plugin
// npm install --save-dev html-webpack-plugin
// In webpack.config.js
var HtmlWebpackPlugin = require('html-webpack-plugin' )
var HTMLWebpackPluginConfig = new HtmlWebpackPlugin({
template: __dirname + '/app/index.html' ,
filename: 'index.html' ,
inject: 'body'
});
module.exports = {
entry: [
'./app/index.js'
],
module: {
loaders: [
{test: /.js$/, exclude: /node_modules/ , loader: "babel-loader" }
]
},
output: {
path: __dirname + '/dist',
filename: "index_bundle.js"
},
plugins: [HTMLWebpackPluginConfig]
}
html template
<!DOCTYPE html>
<html lang= "en">
<head>
<meta charset= "UTF-8">
<title>My App< /title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div id= "app"></div>
</body>
</html>
<!DOCTYPE html>
<html lang= "en">
<head>
<meta charset= "UTF-8">
<title>My App< /title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div id= "app"></div>
<script src="index_bundle.js"></ script>
</body>
</html>
app/index.html
dist/index.html
Further Exploration
loaders: postcss, json, file, url, svg-inline
plugins: CaseSensitivePathsPlugin,
InterpolateHtmlPlugin,
WatchMissingNodeModulesPlugin, DefinePlugin,
OccurrenceOrderPlugin, DedupePlugin
webpack v2!!
Credits
nathf
https://reacttraining.com/
Discussion

More Related Content

What's hot

NodeJS for Beginner
NodeJS for BeginnerNodeJS for Beginner
NodeJS for Beginner
Apaichon Punopas
 
NestJS
NestJSNestJS
NestJS
Wilson Su
 
Its time to React.js
Its time to React.jsIts time to React.js
Its time to React.js
Ritesh Mehrotra
 
React Native
React NativeReact Native
React Native
Craig Jolicoeur
 
Json Web Token - JWT
Json Web Token - JWTJson Web Token - JWT
Json Web Token - JWT
Prashant Walke
 
Express JS
Express JSExpress JS
Express JS
Alok Guha
 
React workshop presentation
React workshop presentationReact workshop presentation
React workshop presentation
Bojan Golubović
 
Getting Started with React.js
Getting Started with React.jsGetting Started with React.js
Getting Started with React.js
Smile Gupta
 
React hooks
React hooksReact hooks
React hooks
Assaf Gannon
 
JavaScript Fetch API
JavaScript Fetch APIJavaScript Fetch API
JavaScript Fetch API
Xcat Liu
 
Basics of React Hooks.pptx.pdf
Basics of React Hooks.pptx.pdfBasics of React Hooks.pptx.pdf
Basics of React Hooks.pptx.pdf
Knoldus Inc.
 
ReactJS presentation
ReactJS presentationReactJS presentation
ReactJS presentation
Thanh Tuong
 
Introducing Swagger
Introducing SwaggerIntroducing Swagger
Introducing Swagger
Tony Tam
 
MongoDB + Java + Spring Data
MongoDB + Java + Spring DataMongoDB + Java + Spring Data
MongoDB + Java + Spring DataAnton Sulzhenko
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
AMD Developer Central
 
React js
React jsReact js
React js
Alireza Akbari
 
React Hooks
React HooksReact Hooks
React Hooks
Erez Cohen
 
Nest.js Introduction
Nest.js IntroductionNest.js Introduction
Nest.js Introduction
Takuya Tejima
 
Introduction to React JS for beginners
Introduction to React JS for beginners Introduction to React JS for beginners
Introduction to React JS for beginners
Varun Raj
 
Node.js Basics
Node.js Basics Node.js Basics
Node.js Basics
TheCreativedev Blog
 

What's hot (20)

NodeJS for Beginner
NodeJS for BeginnerNodeJS for Beginner
NodeJS for Beginner
 
NestJS
NestJSNestJS
NestJS
 
Its time to React.js
Its time to React.jsIts time to React.js
Its time to React.js
 
React Native
React NativeReact Native
React Native
 
Json Web Token - JWT
Json Web Token - JWTJson Web Token - JWT
Json Web Token - JWT
 
Express JS
Express JSExpress JS
Express JS
 
React workshop presentation
React workshop presentationReact workshop presentation
React workshop presentation
 
Getting Started with React.js
Getting Started with React.jsGetting Started with React.js
Getting Started with React.js
 
React hooks
React hooksReact hooks
React hooks
 
JavaScript Fetch API
JavaScript Fetch APIJavaScript Fetch API
JavaScript Fetch API
 
Basics of React Hooks.pptx.pdf
Basics of React Hooks.pptx.pdfBasics of React Hooks.pptx.pdf
Basics of React Hooks.pptx.pdf
 
ReactJS presentation
ReactJS presentationReactJS presentation
ReactJS presentation
 
Introducing Swagger
Introducing SwaggerIntroducing Swagger
Introducing Swagger
 
MongoDB + Java + Spring Data
MongoDB + Java + Spring DataMongoDB + Java + Spring Data
MongoDB + Java + Spring Data
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
React js
React jsReact js
React js
 
React Hooks
React HooksReact Hooks
React Hooks
 
Nest.js Introduction
Nest.js IntroductionNest.js Introduction
Nest.js Introduction
 
Introduction to React JS for beginners
Introduction to React JS for beginners Introduction to React JS for beginners
Introduction to React JS for beginners
 
Node.js Basics
Node.js Basics Node.js Basics
Node.js Basics
 

Viewers also liked

Webpack Tutorial, Uppsala JS
Webpack Tutorial, Uppsala JSWebpack Tutorial, Uppsala JS
Webpack Tutorial, Uppsala JS
Emil Öberg
 
Webpack DevTalk
Webpack DevTalkWebpack DevTalk
Webpack DevTalk
Alessandro Bellini
 
Packing for the Web with Webpack
Packing for the Web with WebpackPacking for the Web with Webpack
Packing for the Web with Webpack
Thiago Temple
 
Webpack
Webpack Webpack
Webpack
DataArt
 
Packing it all: JavaScript module bundling from 2000 to now
Packing it all: JavaScript module bundling from 2000 to nowPacking it all: JavaScript module bundling from 2000 to now
Packing it all: JavaScript module bundling from 2000 to now
Derek Willian Stavis
 
Bundle your modules with Webpack
Bundle your modules with WebpackBundle your modules with Webpack
Bundle your modules with Webpack
Jake Peyser
 
webpack 入門
webpack 入門webpack 入門
webpack 入門
Anna Su
 
Czym jest webpack i dlaczego chcesz go używać?
Czym jest webpack i dlaczego chcesz go używać?Czym jest webpack i dlaczego chcesz go używać?
Czym jest webpack i dlaczego chcesz go używać?
Marcin Gajda
 
Webpack integration
Webpack integrationWebpack integration
Webpack integration
Illia Zub
 
"Webpack: 7 бед — один ответ" — Денис Измайлов, MoscowJS 17
"Webpack: 7 бед — один ответ" — Денис Измайлов, MoscowJS 17"Webpack: 7 бед — один ответ" — Денис Измайлов, MoscowJS 17
"Webpack: 7 бед — один ответ" — Денис Измайлов, MoscowJS 17
MoscowJS
 
Hey webpack
Hey webpackHey webpack
Hey webpack
Andrew Makarow
 
Understanding Objects
Understanding ObjectsUnderstanding Objects
Understanding Objects
R. Sosa
 
Impacto de las tics en la educación cecilia ferreyra
Impacto de las tics en la educación   cecilia ferreyraImpacto de las tics en la educación   cecilia ferreyra
Impacto de las tics en la educación cecilia ferreyra
marianapaniagua
 
Impacto de las TIC\'s en la Cultura de la Mediación a Distancia para la Edu...
Impacto de las TIC\'s en la Cultura de la  Mediación a Distancia para la  Edu...Impacto de las TIC\'s en la Cultura de la  Mediación a Distancia para la  Edu...
Impacto de las TIC\'s en la Cultura de la Mediación a Distancia para la Edu...
Charles Escobar
 
Scaling Community Information Systems
Scaling Community Information SystemsScaling Community Information Systems
Scaling Community Information Systems
Ralf Klamma
 
India Gadget Expo: Emotion Trumps Gadgets
India Gadget Expo: Emotion Trumps GadgetsIndia Gadget Expo: Emotion Trumps Gadgets
India Gadget Expo: Emotion Trumps Gadgets
Levi Shapiro
 
Maken in de Bibliotheek, presentatie bij Platform voor medezeggenschap in de ...
Maken in de Bibliotheek, presentatie bij Platform voor medezeggenschap in de ...Maken in de Bibliotheek, presentatie bij Platform voor medezeggenschap in de ...
Maken in de Bibliotheek, presentatie bij Platform voor medezeggenschap in de ...
Fers
 
Data Science Popup Austin: Surfing Silver Dynamic Bayesian Forecasting for Fu...
Data Science Popup Austin: Surfing Silver Dynamic Bayesian Forecasting for Fu...Data Science Popup Austin: Surfing Silver Dynamic Bayesian Forecasting for Fu...
Data Science Popup Austin: Surfing Silver Dynamic Bayesian Forecasting for Fu...
Domino Data Lab
 
Características Arquitectónicas.
Características Arquitectónicas. Características Arquitectónicas.
Características Arquitectónicas. Fabiana157
 

Viewers also liked (20)

Webpack Tutorial, Uppsala JS
Webpack Tutorial, Uppsala JSWebpack Tutorial, Uppsala JS
Webpack Tutorial, Uppsala JS
 
Webpack DevTalk
Webpack DevTalkWebpack DevTalk
Webpack DevTalk
 
Packing for the Web with Webpack
Packing for the Web with WebpackPacking for the Web with Webpack
Packing for the Web with Webpack
 
Webpack
Webpack Webpack
Webpack
 
Packing it all: JavaScript module bundling from 2000 to now
Packing it all: JavaScript module bundling from 2000 to nowPacking it all: JavaScript module bundling from 2000 to now
Packing it all: JavaScript module bundling from 2000 to now
 
Bundle your modules with Webpack
Bundle your modules with WebpackBundle your modules with Webpack
Bundle your modules with Webpack
 
webpack 入門
webpack 入門webpack 入門
webpack 入門
 
Czym jest webpack i dlaczego chcesz go używać?
Czym jest webpack i dlaczego chcesz go używać?Czym jest webpack i dlaczego chcesz go używać?
Czym jest webpack i dlaczego chcesz go używać?
 
Webpack integration
Webpack integrationWebpack integration
Webpack integration
 
"Webpack: 7 бед — один ответ" — Денис Измайлов, MoscowJS 17
"Webpack: 7 бед — один ответ" — Денис Измайлов, MoscowJS 17"Webpack: 7 бед — один ответ" — Денис Измайлов, MoscowJS 17
"Webpack: 7 бед — один ответ" — Денис Измайлов, MoscowJS 17
 
Hey webpack
Hey webpackHey webpack
Hey webpack
 
Understanding Objects
Understanding ObjectsUnderstanding Objects
Understanding Objects
 
Impacto de las tics en la educación cecilia ferreyra
Impacto de las tics en la educación   cecilia ferreyraImpacto de las tics en la educación   cecilia ferreyra
Impacto de las tics en la educación cecilia ferreyra
 
Impacto de las TIC\'s en la Cultura de la Mediación a Distancia para la Edu...
Impacto de las TIC\'s en la Cultura de la  Mediación a Distancia para la  Edu...Impacto de las TIC\'s en la Cultura de la  Mediación a Distancia para la  Edu...
Impacto de las TIC\'s en la Cultura de la Mediación a Distancia para la Edu...
 
Scaling Community Information Systems
Scaling Community Information SystemsScaling Community Information Systems
Scaling Community Information Systems
 
India Gadget Expo: Emotion Trumps Gadgets
India Gadget Expo: Emotion Trumps GadgetsIndia Gadget Expo: Emotion Trumps Gadgets
India Gadget Expo: Emotion Trumps Gadgets
 
Maken in de Bibliotheek, presentatie bij Platform voor medezeggenschap in de ...
Maken in de Bibliotheek, presentatie bij Platform voor medezeggenschap in de ...Maken in de Bibliotheek, presentatie bij Platform voor medezeggenschap in de ...
Maken in de Bibliotheek, presentatie bij Platform voor medezeggenschap in de ...
 
Data Science Popup Austin: Surfing Silver Dynamic Bayesian Forecasting for Fu...
Data Science Popup Austin: Surfing Silver Dynamic Bayesian Forecasting for Fu...Data Science Popup Austin: Surfing Silver Dynamic Bayesian Forecasting for Fu...
Data Science Popup Austin: Surfing Silver Dynamic Bayesian Forecasting for Fu...
 
Grammar for beginner level
Grammar for beginner levelGrammar for beginner level
Grammar for beginner level
 
Características Arquitectónicas.
Características Arquitectónicas. Características Arquitectónicas.
Características Arquitectónicas.
 

Similar to webpack 101 slides

Introduction to Webpack 5.0 Presentation
Introduction to Webpack 5.0 PresentationIntroduction to Webpack 5.0 Presentation
Introduction to Webpack 5.0 Presentation
Knoldus Inc.
 
How to Webpack your Django!
How to Webpack your Django!How to Webpack your Django!
How to Webpack your Django!
David Gibbons
 
Lecture: Webpack 4
Lecture: Webpack 4Lecture: Webpack 4
Lecture: Webpack 4
Sergei Iastrebov
 
WEBPACK
WEBPACKWEBPACK
WEBPACK
home
 
ReactJS software installation
ReactJS software installationReactJS software installation
ReactJS software installation
HopeTutors1
 
How to install ReactJS software
How to install ReactJS software How to install ReactJS software
How to install ReactJS software
VigneshVijay21
 
webpack introductionNotice Demystifyingf
webpack introductionNotice Demystifyingfwebpack introductionNotice Demystifyingf
webpack introductionNotice Demystifyingf
MrVMNair
 
Building and deploying React applications
Building and deploying React applicationsBuilding and deploying React applications
Building and deploying React applications
Astrails
 
Analysis of bugs in Orchard CMS
Analysis of bugs in Orchard CMSAnalysis of bugs in Orchard CMS
Analysis of bugs in Orchard CMS
PVS-Studio
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteor
Sapna Upreti
 
JavaScript Modules Past, Present and Future
JavaScript Modules Past, Present and FutureJavaScript Modules Past, Present and Future
JavaScript Modules Past, Present and Future
Igalia
 
Hacking the Codename One Source Code - Part V - Transcript.pdf
Hacking the Codename One Source Code - Part V - Transcript.pdfHacking the Codename One Source Code - Part V - Transcript.pdf
Hacking the Codename One Source Code - Part V - Transcript.pdf
ShaiAlmog1
 
Spring Lab
Spring LabSpring Lab
Spring Lab
Leo Nguyen
 
HotPush with Ionic 2 and CodePush
HotPush with Ionic 2 and CodePushHotPush with Ionic 2 and CodePush
HotPush with Ionic 2 and CodePushEvan Schultz
 
Vue fundamentasl with Testing and Vuex
Vue fundamentasl with Testing and VuexVue fundamentasl with Testing and Vuex
Vue fundamentasl with Testing and Vuex
Christoffer Noring
 
Webpack
WebpackWebpack
Code Splitting in Practice - Shanghai JS Meetup May 2016
Code Splitting in Practice - Shanghai JS Meetup May 2016Code Splitting in Practice - Shanghai JS Meetup May 2016
Code Splitting in Practice - Shanghai JS Meetup May 2016
Wiredcraft
 
Readme
ReadmeReadme
Readme
rec2006
 
Solving anything in VCL
Solving anything in VCLSolving anything in VCL
Solving anything in VCL
Fastly
 

Similar to webpack 101 slides (20)

Introduction to Webpack 5.0 Presentation
Introduction to Webpack 5.0 PresentationIntroduction to Webpack 5.0 Presentation
Introduction to Webpack 5.0 Presentation
 
How to Webpack your Django!
How to Webpack your Django!How to Webpack your Django!
How to Webpack your Django!
 
Lecture: Webpack 4
Lecture: Webpack 4Lecture: Webpack 4
Lecture: Webpack 4
 
WEBPACK
WEBPACKWEBPACK
WEBPACK
 
ReactJS software installation
ReactJS software installationReactJS software installation
ReactJS software installation
 
How to install ReactJS software
How to install ReactJS software How to install ReactJS software
How to install ReactJS software
 
webpack introductionNotice Demystifyingf
webpack introductionNotice Demystifyingfwebpack introductionNotice Demystifyingf
webpack introductionNotice Demystifyingf
 
Building and deploying React applications
Building and deploying React applicationsBuilding and deploying React applications
Building and deploying React applications
 
Analysis of bugs in Orchard CMS
Analysis of bugs in Orchard CMSAnalysis of bugs in Orchard CMS
Analysis of bugs in Orchard CMS
 
appledoc_style
appledoc_styleappledoc_style
appledoc_style
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteor
 
JavaScript Modules Past, Present and Future
JavaScript Modules Past, Present and FutureJavaScript Modules Past, Present and Future
JavaScript Modules Past, Present and Future
 
Hacking the Codename One Source Code - Part V - Transcript.pdf
Hacking the Codename One Source Code - Part V - Transcript.pdfHacking the Codename One Source Code - Part V - Transcript.pdf
Hacking the Codename One Source Code - Part V - Transcript.pdf
 
Spring Lab
Spring LabSpring Lab
Spring Lab
 
HotPush with Ionic 2 and CodePush
HotPush with Ionic 2 and CodePushHotPush with Ionic 2 and CodePush
HotPush with Ionic 2 and CodePush
 
Vue fundamentasl with Testing and Vuex
Vue fundamentasl with Testing and VuexVue fundamentasl with Testing and Vuex
Vue fundamentasl with Testing and Vuex
 
Webpack
WebpackWebpack
Webpack
 
Code Splitting in Practice - Shanghai JS Meetup May 2016
Code Splitting in Practice - Shanghai JS Meetup May 2016Code Splitting in Practice - Shanghai JS Meetup May 2016
Code Splitting in Practice - Shanghai JS Meetup May 2016
 
Readme
ReadmeReadme
Readme
 
Solving anything in VCL
Solving anything in VCLSolving anything in VCL
Solving anything in VCL
 

Recently uploaded

Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi ArabiaTop 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Yara Milbes
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
abdulrafaychaudhry
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
ShamsuddeenMuhammadA
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 

Recently uploaded (20)

Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi ArabiaTop 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 

webpack 101 slides

  • 2. What is it's purpose? To bundle your code
  • 3. How does it work?
  • 4. What are some common code transformations?
  • 5. btw...webpack is hard It has terrible documentation
  • 6. 3 main things webpack needs to know 1. the starting point of your application 2. which transformations to make on your code 3. where it should save the new transformed code
  • 7. 1. Specify an entry point // In webpack.config.js module.exports = { entry: [ './app/index.js' ] }
  • 8. 2. Add a loader // In webpack.config.js module.exports = { entry: [ './app/index.js' ], module: { loaders: [ {test: /.js$/, exclude: /node_modules/ , loader: "babel-loader" } ] } }
  • 9. 3. Specify the output // In webpack.config.js module.exports = { entry: [ './app/index.js' ], module: { loaders: [ {test: /.js$/, exclude: /node_modules/ , loader: "babel-loader" } ] }, output: { path: __dirname + '/dist', filename: "index_bundle.js" } }
  • 10. Run webpack // npm install webpack webpack-dev-server // In package.json { "name": "Foo Bar" , "version" : "1.0.0", "description" : "", "main": "index.js" , "scripts" : { "build": "webpack -p" , "start": "webpack-dev-server" }, "author": "", "license" : "ISC", "dependencies" : { "react": "^15.3.2" , "react-dom" : "^15.3.2" }, "devDependencies" : { "babel-core" : "^6.18.2" , "babel-loader" : "^6.2.7", "babel-preset-react" : "^6.16.0" , "html-webpack-plugin" : "^2.24.1" , "webpack" : "^1.13.3" , "webpack-dev-server" : "^1.16.2" } }
  • 11. How do we reference the bundle from HTML? /app - components - containers - config - utils index.js index.html /dist index.html index_bundle.js package.json webpack.config.js .gitignore
  • 12. html-webpack-plugin // npm install --save-dev html-webpack-plugin // In webpack.config.js var HtmlWebpackPlugin = require('html-webpack-plugin' ) var HTMLWebpackPluginConfig = new HtmlWebpackPlugin({ template: __dirname + '/app/index.html' , filename: 'index.html' , inject: 'body' }); module.exports = { entry: [ './app/index.js' ], module: { loaders: [ {test: /.js$/, exclude: /node_modules/ , loader: "babel-loader" } ] }, output: { path: __dirname + '/dist', filename: "index_bundle.js" }, plugins: [HTMLWebpackPluginConfig] }
  • 13. html template <!DOCTYPE html> <html lang= "en"> <head> <meta charset= "UTF-8"> <title>My App< /title> <link rel="stylesheet" href="styles.css"> </head> <body> <div id= "app"></div> </body> </html> <!DOCTYPE html> <html lang= "en"> <head> <meta charset= "UTF-8"> <title>My App< /title> <link rel="stylesheet" href="styles.css"> </head> <body> <div id= "app"></div> <script src="index_bundle.js"></ script> </body> </html> app/index.html dist/index.html
  • 14.
  • 15. Further Exploration loaders: postcss, json, file, url, svg-inline plugins: CaseSensitivePathsPlugin, InterpolateHtmlPlugin, WatchMissingNodeModulesPlugin, DefinePlugin, OccurrenceOrderPlugin, DedupePlugin webpack v2!!