SlideShare ist ein Scribd-Unternehmen logo
1 von 20
Webpack
Just Copy and Paste the configs on GitHub
The History of JavaScript … jk
WATpack
An advanced module bundler… and more
Performance and Integrations
Custom fit for your application’s needs
webpack ./app.js app.bundle.js
Loaders
var moduleWithOneLoader = require("my-loader!./my-awesome-module");
require("loader?with=parameter!./file");
Config
Plugins
webpack-dev-server
Code Splitting
Code Splitting
Multiple Entries
Production Configs
“This is my webpack.config.js. There are many like it, but
this one is mine.”
Resources
https://webpack.github.io/docs/
https://github.com/petehunt/webpack-howto
https://medium.com/@dabit3/beginner-s-guide-to-webpack-b1f1a3638460#.92lbl2myh
http://jonathancreamer.com/advanced-webpack-part-1-the-commonschunk-plugin/
http://jonathancreamer.com/advanced-webpack-part-2-code-splitting/
http://survivejs.com/webpack/advanced-techniques/understanding-chunks/
https://medium.com/@dtothefp/why-can-t-anyone-write-a-simple-webpack-tutorial-
d0b075db35ed#.irh9sqwg4

Weitere ähnliche Inhalte

Was ist angesagt?

Integrating Browserify with Sprockets
Integrating Browserify with SprocketsIntegrating Browserify with Sprockets
Integrating Browserify with Sprockets
Spike Brehm
 
NodeWay in my project & sails.js
NodeWay in my project & sails.jsNodeWay in my project & sails.js
NodeWay in my project & sails.js
Dmytro Ovcharenko
 

Was ist angesagt? (20)

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
 
Packing for the Web with Webpack
Packing for the Web with WebpackPacking for the Web with Webpack
Packing for the Web with Webpack
 
Webpack slides
Webpack slidesWebpack slides
Webpack slides
 
Integration Testing with Behat drupal
Integration Testing with Behat drupalIntegration Testing with Behat drupal
Integration Testing with Behat drupal
 
Webpack: your final module bundler
Webpack: your final module bundlerWebpack: your final module bundler
Webpack: your final module bundler
 
Integrating Browserify with Sprockets
Integrating Browserify with SprocketsIntegrating Browserify with Sprockets
Integrating Browserify with Sprockets
 
Front-end build tools - Webpack
Front-end build tools - WebpackFront-end build tools - Webpack
Front-end build tools - Webpack
 
002. Working with Webpack
002. Working with Webpack002. Working with Webpack
002. Working with Webpack
 
Nuxt.js - Introduction
Nuxt.js - IntroductionNuxt.js - Introduction
Nuxt.js - Introduction
 
Nuxt Talk
Nuxt TalkNuxt Talk
Nuxt Talk
 
Production optimization with React and Webpack
Production optimization with React and WebpackProduction optimization with React and Webpack
Production optimization with React and Webpack
 
Sails.js Intro
Sails.js IntroSails.js Intro
Sails.js Intro
 
NodeWay in my project & sails.js
NodeWay in my project & sails.jsNodeWay in my project & sails.js
NodeWay in my project & sails.js
 
Bower power
Bower powerBower power
Bower power
 
DotNet MVC and webpack + Babel + react
DotNet MVC and webpack + Babel + reactDotNet MVC and webpack + Babel + react
DotNet MVC and webpack + Babel + react
 
005. a React project structure
005. a React project structure005. a React project structure
005. a React project structure
 
Grunt and Bower
Grunt and BowerGrunt and Bower
Grunt and Bower
 
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and GulpOptimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
 
Introduction of webpack 4
Introduction of webpack 4Introduction of webpack 4
Introduction of webpack 4
 
An Overview on Nuxt.js
An Overview on Nuxt.jsAn Overview on Nuxt.js
An Overview on Nuxt.js
 

Andere mochten auch

QG CERT (1)
QG CERT (1)QG CERT (1)
QG CERT (1)
ali asif
 
CERTIFICATE IN OIL AND GAS MANAGEMENT
CERTIFICATE IN OIL AND GAS MANAGEMENTCERTIFICATE IN OIL AND GAS MANAGEMENT
CERTIFICATE IN OIL AND GAS MANAGEMENT
kayode oluwadare
 

Andere mochten auch (18)

stop building, start listening
stop building, start listeningstop building, start listening
stop building, start listening
 
Graphical Data Exploration
Graphical Data ExplorationGraphical Data Exploration
Graphical Data Exploration
 
QG CERT (1)
QG CERT (1)QG CERT (1)
QG CERT (1)
 
LOPEZ SANTIAGO RAUL
LOPEZ SANTIAGO RAULLOPEZ SANTIAGO RAUL
LOPEZ SANTIAGO RAUL
 
CERTIFICATE IN OIL AND GAS MANAGEMENT
CERTIFICATE IN OIL AND GAS MANAGEMENTCERTIFICATE IN OIL AND GAS MANAGEMENT
CERTIFICATE IN OIL AND GAS MANAGEMENT
 
Android Crash Course lunch and learn (1 of 2)
Android Crash Course lunch and learn (1 of 2)Android Crash Course lunch and learn (1 of 2)
Android Crash Course lunch and learn (1 of 2)
 
Auth done right - OpenID Connect with IdentityServer @ DotNetCrowd, Vilnius
Auth done right - OpenID Connect with IdentityServer @ DotNetCrowd, VilniusAuth done right - OpenID Connect with IdentityServer @ DotNetCrowd, Vilnius
Auth done right - OpenID Connect with IdentityServer @ DotNetCrowd, Vilnius
 
Automação de testes funcionais com Python e Mechanize
Automação de testes funcionais com Python e MechanizeAutomação de testes funcionais com Python e Mechanize
Automação de testes funcionais com Python e Mechanize
 
Super keyword in java
Super keyword in javaSuper keyword in java
Super keyword in java
 
IdentityServer 4
IdentityServer 4IdentityServer 4
IdentityServer 4
 
Hey webpack
Hey webpackHey webpack
Hey webpack
 
Webpack integration
Webpack integrationWebpack integration
Webpack integration
 
"Webpack: 7 бед — один ответ" — Денис Измайлов, MoscowJS 17
"Webpack: 7 бед — один ответ" — Денис Измайлов, MoscowJS 17"Webpack: 7 бед — один ответ" — Денис Измайлов, MoscowJS 17
"Webpack: 7 бед — один ответ" — Денис Измайлов, MoscowJS 17
 
Как Webpack сделал меня счастливее
Как Webpack сделал меня счастливееКак Webpack сделал меня счастливее
Как Webpack сделал меня счастливее
 
Webpack - Czym jest webpack i dlaczego chcesz go używać? - wersja krótka
Webpack - Czym jest webpack i dlaczego chcesz go używać? - wersja krótkaWebpack - Czym jest webpack i dlaczego chcesz go używać? - wersja krótka
Webpack - Czym jest webpack i dlaczego chcesz go używać? - wersja krótka
 
Современный фронтенд -- как не утонуть в море хайпа?
Современный фронтенд -- как не утонуть в море хайпа?Современный фронтенд -- как не утонуть в море хайпа?
Современный фронтенд -- как не утонуть в море хайпа?
 
Современный фронтенд за 30 минут.
Современный фронтенд за 30 минут.Современный фронтенд за 30 минут.
Современный фронтенд за 30 минут.
 
Modernize Development with Agile Engineering Practices
Modernize Development with Agile Engineering PracticesModernize Development with Agile Engineering Practices
Modernize Development with Agile Engineering Practices
 

Ähnlich wie Webpack

20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev
Frank Rousseau
 
webpack introductionNotice Demystifyingf
webpack introductionNotice Demystifyingfwebpack introductionNotice Demystifyingf
webpack introductionNotice Demystifyingf
MrVMNair
 

Ähnlich wie Webpack (20)

WEBPACK
WEBPACKWEBPACK
WEBPACK
 
How to Webpack your Django!
How to Webpack your Django!How to Webpack your Django!
How to Webpack your Django!
 
Introduction to Webpack 5.0 Presentation
Introduction to Webpack 5.0 PresentationIntroduction to Webpack 5.0 Presentation
Introduction to Webpack 5.0 Presentation
 
Webpack presentation
Webpack presentationWebpack presentation
Webpack presentation
 
20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev
 
DevOps hackathon Session 2: Basics of Chef
DevOps hackathon Session 2: Basics of ChefDevOps hackathon Session 2: Basics of Chef
DevOps hackathon Session 2: Basics of Chef
 
Rails + Webpack
Rails + WebpackRails + Webpack
Rails + Webpack
 
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
 
Webpack 살펴보기
Webpack 살펴보기Webpack 살펴보기
Webpack 살펴보기
 
No more Dockerfiles? Buildpacks to help you ship your image!
No more Dockerfiles? Buildpacks to help you ship your image!No more Dockerfiles? Buildpacks to help you ship your image!
No more Dockerfiles? Buildpacks to help you ship your image!
 
Installing Webpack with React JS from Scratch.pdf
Installing Webpack with React JS from Scratch.pdfInstalling Webpack with React JS from Scratch.pdf
Installing Webpack with React JS from Scratch.pdf
 
Slim3 quick start
Slim3 quick startSlim3 quick start
Slim3 quick start
 
Curing Webpack Cancer
Curing Webpack CancerCuring Webpack Cancer
Curing Webpack Cancer
 
Vagrant or docker for java dev environment
Vagrant or docker for java dev environmentVagrant or docker for java dev environment
Vagrant or docker for java dev environment
 
Building JavaScript
Building JavaScriptBuilding JavaScript
Building JavaScript
 
How Bitbucket Pipelines Loads Connect UI Assets Super-fast
How Bitbucket Pipelines Loads Connect UI Assets Super-fastHow Bitbucket Pipelines Loads Connect UI Assets Super-fast
How Bitbucket Pipelines Loads Connect UI Assets Super-fast
 
Create a module bundler from scratch
Create a module bundler from scratchCreate a module bundler from scratch
Create a module bundler from scratch
 
webpack 101 slides
webpack 101 slideswebpack 101 slides
webpack 101 slides
 
Bundle Splitting in Volto
Bundle Splitting in VoltoBundle Splitting in Volto
Bundle Splitting in Volto
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Kürzlich hochgeladen (20)

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 

Hinweis der Redaktion

  1. Let’s talk about documentation…
  2. Split the dependency tree into chunks loaded on demand Keep initial loading time low Ability to integrate 3rd-party libraries as modules Ability to customize nearly every part of the module bundler Suited for big projects Configuration-based systems are preferable to imperative systems if they make the right assumptions about your goals up front. Webpack assumes you need to move files from a source directory to a destination directory. It assumes you want to work with JavaScript libraries in various module formats like CommonJS, and AMD. It assumes you’ll want to compile various formats using a long list of loaders. Sure, you can do all this via Browserify and Gulp, but you have to do more wiring yourself. And you’re manually wiring together two totally separate technologies.
  3. Basic webpack usage Jump to console
  4. http://webpack.github.io/docs/loaders.html Specifying loaders in each module request can be brittle and repetitive. Webpack provides a way to specify which loaders apply to different file types in your Webpack configuration file. Specifying loaders in the configuration is the recommended approach in most cases as it doesn’t add any build specific syntax to the code, making it more reusable. After the file is read from the filesystem, loaders are executed against it in the following order. preloaders specified in the configuration loaders specified in the configuration loaders specified in the request (e.g. require('raw!./file.js')) postLoaders specified in the configuration You can also override the configuration loader order in the module request to suit special cases. You can write custom loaders: Sync Async Raw By default the resource file is treated as utf-8 string and passed as String to the loader. By setting raw to true the loader is passed the raw Buffer.
  5. http://webpack.github.io/docs/loaders.html Basic loader
  6. http://webpack.github.io/docs/loaders.html Loader with parameter The format of the query string is up to the loader, so check the loaders documentation to find out about the parameters the loader accept, but generally most loaders support the traditional query string format.
  7. http://webpack.github.io/docs/usage.html
  8. http://webpack.github.io/docs/usage.html
  9. http://webpack.github.io/docs/usage.html We are excluding node_modules here because otherwise all external libraries will also go through Babel, slowing down compilation.
  10. http://webpack.github.io/docs/usage.html The Uglify plugin is included with webpack so you don’t need to add additional modules, but this may not always be the case. You can write your own custom plugins. For this build, the uglify plugin cut the bundle size from 1618 bytes to 308 bytes
  11. https://webpack.github.io/docs/plugins.html Eh… go read. Write your own. Basically, these have access to some of the internal webpack objects, and they have a plugin method that allows you to inject custom build steps. Think of MS Build Tasks The plugin calls bind callbacks to fire at specific steps throughout the build process. A plugin is installed once as Webpack starts up. Webpack installs a plugin by calling its apply method, and passes a reference to the Webpack compiler object. You may then call compiler.plugin to access asset compilations and their individual build steps.
  12. https://webpack.github.io/docs/webpack-dev-server.html Uses a small expressJS server and webpack-dev-middleware to serve a webpack bundle Also has a runtime attached via Socket.IO Server emits info about compilation state to the client The webpack-dev-server will serve the files in the current directory, unless you configure a specific content base.
  13. https://webpack.github.io/doc It’s an opt-in feature. You can define split points in your code base. Webpack takes care of the dependencies, output files and runtime stuff. To clarify a common misunderstanding: Code Splitting is not just about extracting common code into a shared chunk. The more notable feature is that Code Splitting can be used to split code into an on demand loaded chunk. This can keep the initial download small and downloads code on demand when requested by the application. s/code-splitting.html CommonJS: require.ensure(dependencies, callback) Note: require.ensure only loads the modules, it doesn’t evaluate them. The require.ensure method ensures that every dependency in dependencies can be synchronously required when calling the callback. callback is called with the require function as parameter. AMD: require(dependencies, callback) When called, all dependencies are loaded and the callback is called with the exports of the loaded dependencies. tl;dr: Webpack doesn’t support ES6 modules; use require.ensure or require directly depending on which module format your transpiler creates.
  14. https://webpack.github.io/docs/code-splitting.html If two chunks contain the same modules, they are merged into one. This can cause chunks to have multiple parents. If a module is available in all parents of a chunk, it’s removed from that chunk. If a chunk contains all modules of another chunk, this is stored. It fulfills multiple chunks. Depending on the configuration option target a runtime logic for chunk loading is added to the bundle. I. e. for the web target chunks are loaded via jsonp. A chunk is only loaded once and parallel requests are merged into one. The runtime checks for loaded chunks whether they fulfill multiple chunks. Entry chunk An entry chunk contains the runtime plus a bunch of modules. If the chunk contains the module 0the runtime executes it. If not, it waits for chunks that contains the module 0 and executes it (every time when there is a chunk with a module 0). Normal chunk A normal chunk contains no runtime. It only contains a bunch of modules. The structure depends on the chunk loading algorithm. I. e. for jsonp the modules are wrapped in a jsonp callback function. The chunk also contains a list of chunk id that it fulfills. Initial chunk (non-entry) An initial chunk is a normal chunk. The only difference is that optimization treats it as more important because it counts toward the initial loading time (like entry chunks). That chunk type can occur in combination with the CommonsChunkPlugin.
  15. With the CommonsChunkPlugin the runtime is moved to the commons chunk. The entry points are now in initial chunks. While only one initial chunk can be loaded, multiple entry chunks can be loaded. This exposes the possibility to run multiple entry points in a single page.
  16. webpack -p --config webpack.production.config.js -d includes source maps
  17. https://medium.com/@dtothefp/why-can-t-anyone-write-a-simple-webpack-tutorial-d0b075db35ed#.irh9sqwg4
  18. Enhance debugging with sourcemaps, linters, etc.