SlideShare a Scribd company logo
WEBPACK ENCORE
Asset management for the rest of us
2
Stefan Adolf
Developer Ambassador
#javascript #mongodb #serverless
#blockchain #codingberlin #elastic
#aws #php #symfony2 #react
#digitalization #agile #b2b #marketplaces
#spryker #php #k8s #largescale
#turbinejetzt #iot #ux #vuejs
@stadolf
elmariachi111
FRONTEND.
THE FINAL FRONTIER.
3
4
•Many flavors
•ECMAScript 5-8 / 2009-2017,
TypeScript, CoffeScript, Flow
•Many frameworks
•JQuery, Backbone, Ember
•React/JSX, Angular, Vue.js
•importing dependencies lately solved.
•it’s a moving target.
Frontend: the final frontier.
•Lots of quirks, lots of frameworks
•LESS, Sass / SCSS, Compass
•SMACSS, BEM, Atomic CSS
•Tools, tools, tools:
•PostCss,
•Autoprefixer
•Reboots
•css-modules
•styled
•CSSinJS
5
var APP = APP || {};
APP.Frontend = APP.Frontend || {};
APP.Frontend.Clock = function($el) {
this.time = moment();
this.$el = $el;
}
APP.Frontend.Clock.prototype = {
getServerTime: function() {
$.get('http://fixed.url.com', function(err, res) {
this.time = moment(res.time)
this.$el.text(this.time.format("HH:ii"))
})
}
}
var clock = new APP.Frontend.Clock($('#clock-div'));
clock.getServerTime();
some old javascript.
<script src="jquery.js"></script>
<script src="bootstrap.min.js"></script>
<script src="moment.js"></script>
<script src="app.js"></script>
6
define('my/module',
['jquery', 'lodash', 'moment'],
function($, _, moment) {
var Clock = function($el) {
this.time = moment();
this.$el = $el;
}
Clock.prototype = {
getServerTime: function() {
$.get('http://fixed.url.com', function(err, res) {
this.time = moment(res.time)
this.$el.text(this.time.format("HH:ii"))
})
}
}
var clock = new Clock($('#clock-div'));
clock.getServerTime();
return clock;
})
some quite old javascript.
<script src=“require.js"></script>
<script src="app.js"></script>
7
var $ = require('jquery');
var _ = require('lodash');
var moment = require('moment');
class Clock {
constructor($el) {
this.time = moment();
this.$el = $el;
}
getServerTime() {
$.get('http://fixed.url.com', (err, res) => {
this.time = moment(res.time)
this.$el.text(this.time.format("HH:ii"))
})
}
}
var clock = new Clock($('#clock-div'));
clock.getServerTime();
module.exports = clock;
some recent javascript.
$ gulp build
<script src="app.js"></script>
8
What I really need
•latest Javascript language features
•dependency management
•SCSS compilation
•live browser reloading
•debugging in the browser
•support for old frameworks
•don’t take care for old browsers
•fast loading times on production
•fast build times
•instantly useable by new team members
Boot

strap
scssscss scss scss
product_list.html.twig
product_single.html.twig
checkout.html.twig
$ lodash moment urljs
Boot

strap.js
JS JS JS
JS
JS
JS
JS JS JS
JS
JS
JS
product.css product.js checkout.jscheckout.css
a not so unusual frontend requirement in “fullstack” scenarios
10
11
Webpack is a module bundler
and not a “build” tool.
12
THEY ALL TRUST WEBPACK.
BECAUSE IT’S SO GREAT.
13
•initial setup = no brainer
•Javascript files are the root of truth
•require scss, images, fonts, data, templates
•webpack can take care of
•JS transpilation
•browser compatibility & polyfilling
•image optimization
•SCSS compilation & extraction
•asset copying / concatenation
webpack core
14
•babel integration
•write modern javascript
•transpile Typescript
•sourcemaps
•style inlining / css components
•versioning
•long term caching
•tree shaking
•~ dead code removal
•chunk control
•common chunks
•intelligent entrypoint commons
•enables framework syntaxes like
•React JSX
•Vue single file components
•developer experience
•file watching
•dev-server (reload on build)
•HMR (inject changes)
•code metrics
webpack advanced
15
FINALLY WE CAN WRITE NICE JAVASCRIPT
Demo
16
const path = require("path");
const webpack = require("webpack");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const ManifestPlugin = require("webpack-manifest-plugin");
const provide = new webpack.ProvidePlugin({
$: "cash-dom",
jQuery: "cash-dom"
});
module.exports = {
entry: {
index: "./assets/js/index.js"
},
output: {
filename: "[name].[hash].js",
publicPath: "/dist/",
path: path.resolve(__dirname, "public/dist")
},
plugins: [
new CleanWebpackPlugin(["public/dist"]),
new ManifestPlugin({
writeToFileEmit: true
}),
provide
],
module: {
rules: [
{
test: /.(sa|sc|c)ss$/,
use: [
"style-loader",
"css-loader",
{
loader: "postcss-loader",
options: {
ident: "postcss",
plugins: [require("autoprefixer")()]
}
},
"sass-loader"
]
},
{
test: /.js$/,
exclude: /(node_modules|bower_components)/,
const merge = require("webpack-merge");
const common = require("./webpack.common.js");
const webpack = require("webpack");
module.exports = merge(common, {
mode: "development",
devtool: "cheap-module-eval-source-map", //inline-source-map,
output: {
publicPath: "http://localhost:8080/dist/"
},
devServer: {
host: "localhost",
publicPath: "/dist/",
https: false,
contentBase: "./public/dist",
hot: true,
inline: true,
headers: {
"Access-Control-Allow-Origin": "*"
}
},
plugins: [
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin()
]
});
const merge = require("webpack-merge");
const common = require("./webpack.common.js");
const UglifyJsPlugin = require("uglifyjs-webpack-plugin")
const OptimizeCssAssetsPlugin = require("optimize-css-ass
const MiniCssExtractPlugin = require("mini-css-extract-pl
module.exports = merge(common, {
mode: "production",
//devtool: "source-map",
plugins: [
new MiniCssExtractPlugin({
filename: "[name].[hash].css",
chunkFilename: "[id].[hash].css"
})
],
optimization: {
minimizer: [
new UglifyJsPlugin({
cache: true,
parallel: true,
sourceMap: false // set to true if you want JS so
}),
new OptimizeCssAssetsPlugin({})
],
runtimeChunk: "single",
splitChunks: {
cacheGroups: {
vendor: {
test: /[/]node_modules[/]/,
name: "vendors",
chunks: "all"
}
}
}
},
module: {
rules: [
{
test: /.(sa|sc|c)ss$/,
use: [
MiniCssExtractPlugin.loader,
//"style-loader",
"css-loader",
//'postcss-loader',
"sass-loader"
]
}
]
}
});
FINALLY WE CAN WRITE NICE JAVASCRIPT?
encore
is a webpack configuration generator
composer require symfony/webpack-encore-pack
install
npm i -D @symfony/webpack-encore
or
20
const Encore = require("@symfony/webpack-encore");
Encore.setOutputPath("public/dist/")
.setPublicPath("/dist")
.addEntry("index", "./assets/js/index.js")
.cleanupOutputBeforeBuild()
.enableSourceMaps(!Encore.isProduction())
.enableVersioning(Encore.isProduction())
.enableSassLoader()
.enablePostCssLoader()
.enableSingleRuntimeChunk()
.createSharedEntry("vendor", “./assets/js/vendor.js");
.autoProvideVariables({
$: "cash-dom",
jQuery: "cash-dom"
})
module.exports = Encore.getWebpackConfig();
the same thing in encore.
multiple entries
dev tools
dev/prod mode
css loading & transformation
chunking / splitting
global variable shimming
all dev tools included
automatic manifests / caches
living on the edge.
I’m using encore 0.21 here.
That’s ~134 commits ahead of the documented stable release.
Demo
.enableReactPreset()
npm install @babel/preset-react@^7.0.0 --save-dev
.enableVueLoader()
npm install vue vue-loader@^15.0.11 vue-template-compiler --save-dev
24
•Webpack 2 -> Webpack 4
•“shared commons entries” -> split chunks plugin
•dedicated vendor / client code chunks for entries
•“vendors.js & manifest.json” will be replaced with “entrypoints.json”
•every page gets exactly what it needs
•shared runtime chunk
•contains the webpack runtime for all pages
•dynamic imports (lazy loading specialized libraries / features)
•Handlebars loader built in
upcoming in the next release
25
•massively reduces effort to enable modern frontend features
•by being highly opinionated
•integrates perfectly into Symfony applications
•the simplest way to enable modern frontend support
•perfect tool to start migrating old frontend code
•not so great to start a SPA/PWA/AMP project (use vue.cli or c-r-app instead)
•it just generates configuration
•you can always add your own config
•simple to “down”grade to plain webpack
•you can even use it outside a Symfony context
•the current release is stable and production ready.
•don’t use the bleeding edge master yet!!
wrap up
Turbine Kreuzberg GmbH
Ohlauer Straße 43
10999 Berlin
ASSET MANAGEMENT
FOR THE REST OF US.
@stadolf
#turbinejetzt
hello@turbinekreuzberg.com
https://github.com/elmariachi111/encore-demo

More Related Content

PDF
Webpack Encore - Asset Management for the rest of us
PDF
Sails.js Intro
PDF
Front-end build tools - Webpack
PPTX
DotNet MVC and webpack + Babel + react
PPTX
Webpack Introduction
PPTX
Webpack
PPT
Build Your Own CMS with Apache Sling
PDF
OSGi, Scripting and REST, Building Webapps With Apache Sling
Webpack Encore - Asset Management for the rest of us
Sails.js Intro
Front-end build tools - Webpack
DotNet MVC and webpack + Babel + react
Webpack Introduction
Webpack
Build Your Own CMS with Apache Sling
OSGi, Scripting and REST, Building Webapps With Apache Sling

What's hot (20)

PDF
RESTful Web Applications with Apache Sling
PDF
Bundle your modules with Webpack
PPTX
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
PPTX
Improving build solutions dependency management with webpack
PDF
Advanced front-end automation with npm scripts
PDF
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
PDF
Webpack: from 0 to 2
PDF
Webpack DevTalk
PPTX
Packing for the Web with Webpack
PDF
Native-Javascript Bridging Using WKWebViews in iOS8
PDF
Webpack
PDF
FITC - Here Be Dragons: Advanced JavaScript Debugging
PDF
WKWebView in Production
PDF
Vue 淺談前端建置工具
PPTX
Webpack and Web Performance Optimization
PDF
Hey webpack
PDF
Grunt.js and Yeoman, Continous Integration
PDF
Sails.js Model / ORM introduce
PPT
RESTful Web Applications with Apache Sling
Bundle your modules with Webpack
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
Improving build solutions dependency management with webpack
Advanced front-end automation with npm scripts
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
Webpack: from 0 to 2
Webpack DevTalk
Packing for the Web with Webpack
Native-Javascript Bridging Using WKWebViews in iOS8
Webpack
FITC - Here Be Dragons: Advanced JavaScript Debugging
WKWebView in Production
Vue 淺談前端建置工具
Webpack and Web Performance Optimization
Hey webpack
Grunt.js and Yeoman, Continous Integration
Sails.js Model / ORM introduce
Ad

Similar to (2018) Webpack Encore - Asset Management for the rest of us (20)

PDF
AFUP Lorraine - Symfony Webpack Encore
PDF
OUTDATED (Encore)
PDF
Symfony Live 2018 - Développez votre frontend avec ReactJS et Symfony Webpack...
PPTX
webpack introductionNotice Demystifyingf
PDF
Modern UI Development With Node.js
PDF
Keeping the frontend under control with Symfony and Webpack
PDF
Webpack Encore Symfony Live 2017 San Francisco
PDF
Creating a full stack web app with python, npm, webpack and react
PPTX
WEBPACK
PDF
ReactJS Workflows
PPTX
Node.js Web Apps @ ebay scale
PPT
PDF
Webpack presentation
PDF
Symfony and frontend: a better way
PDF
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
PDF
Webpack: What it is, What it does, Whether you need it
PDF
Building and deploying React applications
PDF
Hitchhiker's guide to the front end development
PPTX
Professionalizing the Front-end
PPTX
web development full stack
AFUP Lorraine - Symfony Webpack Encore
OUTDATED (Encore)
Symfony Live 2018 - Développez votre frontend avec ReactJS et Symfony Webpack...
webpack introductionNotice Demystifyingf
Modern UI Development With Node.js
Keeping the frontend under control with Symfony and Webpack
Webpack Encore Symfony Live 2017 San Francisco
Creating a full stack web app with python, npm, webpack and react
WEBPACK
ReactJS Workflows
Node.js Web Apps @ ebay scale
Webpack presentation
Symfony and frontend: a better way
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Webpack: What it is, What it does, Whether you need it
Building and deploying React applications
Hitchhiker's guide to the front end development
Professionalizing the Front-end
web development full stack
Ad

More from Stefan Adolf (20)

PDF
Blockchains - Technical foundations
PDF
HOW TO SURVIVE A 2DAY HACKATHON?
PDF
Digitale Selbstbestimmung mit Hilfe dezentraler Technologien
PDF
Digitale Selbstbestimmung | Anwendungsfälle der Dezentralität
PDF
Decentralized technology: a (short) survey
PDF
Productive web applications that run only on the frontend
PDF
DePA - die dezentrale Patientenakte (29.1. FU Berlin)
PDF
DePA - die dezentrale Patientenakte
PDF
Was ist eine Datenbank - und was hat Blockchain damit zu tun?
PDF
Never Code Alone: Von Symfony Forms zu einer SPA auf APIs
PDF
Decentralize all the things
PDF
Indexing Decentralized Data with Ethereum, IPFS & The Graph
PDF
Gatsby (Code.Talks) 2019
PDF
A micro service story
PDF
Api Platform: the ultimate API Platform
PDF
Pump up the JAM with Gatsby (2019)
PDF
Testing API platform with Behat BDD tests
PDF
Hack it like its hot!
PDF
api-platform: the ultimate API platform
PDF
Pump up the JAM with Gatsby
Blockchains - Technical foundations
HOW TO SURVIVE A 2DAY HACKATHON?
Digitale Selbstbestimmung mit Hilfe dezentraler Technologien
Digitale Selbstbestimmung | Anwendungsfälle der Dezentralität
Decentralized technology: a (short) survey
Productive web applications that run only on the frontend
DePA - die dezentrale Patientenakte (29.1. FU Berlin)
DePA - die dezentrale Patientenakte
Was ist eine Datenbank - und was hat Blockchain damit zu tun?
Never Code Alone: Von Symfony Forms zu einer SPA auf APIs
Decentralize all the things
Indexing Decentralized Data with Ethereum, IPFS & The Graph
Gatsby (Code.Talks) 2019
A micro service story
Api Platform: the ultimate API Platform
Pump up the JAM with Gatsby (2019)
Testing API platform with Behat BDD tests
Hack it like its hot!
api-platform: the ultimate API platform
Pump up the JAM with Gatsby

Recently uploaded (20)

PPTX
L1 - Introduction to python Backend.pptx
PPT
Introduction Database Management System for Course Database
PDF
AI in Product Development-omnex systems
PPTX
history of c programming in notes for students .pptx
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
ai tools demonstartion for schools and inter college
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
medical staffing services at VALiNTRY
PDF
top salesforce developer skills in 2025.pdf
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
L1 - Introduction to python Backend.pptx
Introduction Database Management System for Course Database
AI in Product Development-omnex systems
history of c programming in notes for students .pptx
ManageIQ - Sprint 268 Review - Slide Deck
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Design an Analysis of Algorithms I-SECS-1021-03
ai tools demonstartion for schools and inter college
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
VVF-Customer-Presentation2025-Ver1.9.pptx
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
medical staffing services at VALiNTRY
top salesforce developer skills in 2025.pdf
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Design an Analysis of Algorithms II-SECS-1021-03
Navsoft: AI-Powered Business Solutions & Custom Software Development
How to Migrate SBCGlobal Email to Yahoo Easily

(2018) Webpack Encore - Asset Management for the rest of us

  • 1. WEBPACK ENCORE Asset management for the rest of us
  • 2. 2 Stefan Adolf Developer Ambassador #javascript #mongodb #serverless #blockchain #codingberlin #elastic #aws #php #symfony2 #react #digitalization #agile #b2b #marketplaces #spryker #php #k8s #largescale #turbinejetzt #iot #ux #vuejs @stadolf elmariachi111
  • 4. 4 •Many flavors •ECMAScript 5-8 / 2009-2017, TypeScript, CoffeScript, Flow •Many frameworks •JQuery, Backbone, Ember •React/JSX, Angular, Vue.js •importing dependencies lately solved. •it’s a moving target. Frontend: the final frontier. •Lots of quirks, lots of frameworks •LESS, Sass / SCSS, Compass •SMACSS, BEM, Atomic CSS •Tools, tools, tools: •PostCss, •Autoprefixer •Reboots •css-modules •styled •CSSinJS
  • 5. 5 var APP = APP || {}; APP.Frontend = APP.Frontend || {}; APP.Frontend.Clock = function($el) { this.time = moment(); this.$el = $el; } APP.Frontend.Clock.prototype = { getServerTime: function() { $.get('http://fixed.url.com', function(err, res) { this.time = moment(res.time) this.$el.text(this.time.format("HH:ii")) }) } } var clock = new APP.Frontend.Clock($('#clock-div')); clock.getServerTime(); some old javascript. <script src="jquery.js"></script> <script src="bootstrap.min.js"></script> <script src="moment.js"></script> <script src="app.js"></script>
  • 6. 6 define('my/module', ['jquery', 'lodash', 'moment'], function($, _, moment) { var Clock = function($el) { this.time = moment(); this.$el = $el; } Clock.prototype = { getServerTime: function() { $.get('http://fixed.url.com', function(err, res) { this.time = moment(res.time) this.$el.text(this.time.format("HH:ii")) }) } } var clock = new Clock($('#clock-div')); clock.getServerTime(); return clock; }) some quite old javascript. <script src=“require.js"></script> <script src="app.js"></script>
  • 7. 7 var $ = require('jquery'); var _ = require('lodash'); var moment = require('moment'); class Clock { constructor($el) { this.time = moment(); this.$el = $el; } getServerTime() { $.get('http://fixed.url.com', (err, res) => { this.time = moment(res.time) this.$el.text(this.time.format("HH:ii")) }) } } var clock = new Clock($('#clock-div')); clock.getServerTime(); module.exports = clock; some recent javascript. $ gulp build <script src="app.js"></script>
  • 8. 8 What I really need •latest Javascript language features •dependency management •SCSS compilation •live browser reloading •debugging in the browser •support for old frameworks •don’t take care for old browsers •fast loading times on production •fast build times •instantly useable by new team members
  • 9. Boot
 strap scssscss scss scss product_list.html.twig product_single.html.twig checkout.html.twig $ lodash moment urljs Boot
 strap.js JS JS JS JS JS JS JS JS JS JS JS JS product.css product.js checkout.jscheckout.css a not so unusual frontend requirement in “fullstack” scenarios
  • 10. 10
  • 11. 11 Webpack is a module bundler and not a “build” tool.
  • 12. 12 THEY ALL TRUST WEBPACK. BECAUSE IT’S SO GREAT.
  • 13. 13 •initial setup = no brainer •Javascript files are the root of truth •require scss, images, fonts, data, templates •webpack can take care of •JS transpilation •browser compatibility & polyfilling •image optimization •SCSS compilation & extraction •asset copying / concatenation webpack core
  • 14. 14 •babel integration •write modern javascript •transpile Typescript •sourcemaps •style inlining / css components •versioning •long term caching •tree shaking •~ dead code removal •chunk control •common chunks •intelligent entrypoint commons •enables framework syntaxes like •React JSX •Vue single file components •developer experience •file watching •dev-server (reload on build) •HMR (inject changes) •code metrics webpack advanced
  • 15. 15 FINALLY WE CAN WRITE NICE JAVASCRIPT Demo
  • 16. 16 const path = require("path"); const webpack = require("webpack"); const CleanWebpackPlugin = require("clean-webpack-plugin"); const ManifestPlugin = require("webpack-manifest-plugin"); const provide = new webpack.ProvidePlugin({ $: "cash-dom", jQuery: "cash-dom" }); module.exports = { entry: { index: "./assets/js/index.js" }, output: { filename: "[name].[hash].js", publicPath: "/dist/", path: path.resolve(__dirname, "public/dist") }, plugins: [ new CleanWebpackPlugin(["public/dist"]), new ManifestPlugin({ writeToFileEmit: true }), provide ], module: { rules: [ { test: /.(sa|sc|c)ss$/, use: [ "style-loader", "css-loader", { loader: "postcss-loader", options: { ident: "postcss", plugins: [require("autoprefixer")()] } }, "sass-loader" ] }, { test: /.js$/, exclude: /(node_modules|bower_components)/, const merge = require("webpack-merge"); const common = require("./webpack.common.js"); const webpack = require("webpack"); module.exports = merge(common, { mode: "development", devtool: "cheap-module-eval-source-map", //inline-source-map, output: { publicPath: "http://localhost:8080/dist/" }, devServer: { host: "localhost", publicPath: "/dist/", https: false, contentBase: "./public/dist", hot: true, inline: true, headers: { "Access-Control-Allow-Origin": "*" } }, plugins: [ new webpack.NamedModulesPlugin(), new webpack.HotModuleReplacementPlugin() ] }); const merge = require("webpack-merge"); const common = require("./webpack.common.js"); const UglifyJsPlugin = require("uglifyjs-webpack-plugin") const OptimizeCssAssetsPlugin = require("optimize-css-ass const MiniCssExtractPlugin = require("mini-css-extract-pl module.exports = merge(common, { mode: "production", //devtool: "source-map", plugins: [ new MiniCssExtractPlugin({ filename: "[name].[hash].css", chunkFilename: "[id].[hash].css" }) ], optimization: { minimizer: [ new UglifyJsPlugin({ cache: true, parallel: true, sourceMap: false // set to true if you want JS so }), new OptimizeCssAssetsPlugin({}) ], runtimeChunk: "single", splitChunks: { cacheGroups: { vendor: { test: /[/]node_modules[/]/, name: "vendors", chunks: "all" } } } }, module: { rules: [ { test: /.(sa|sc|c)ss$/, use: [ MiniCssExtractPlugin.loader, //"style-loader", "css-loader", //'postcss-loader', "sass-loader" ] } ] } }); FINALLY WE CAN WRITE NICE JAVASCRIPT?
  • 17. encore is a webpack configuration generator
  • 19. npm i -D @symfony/webpack-encore or
  • 20. 20 const Encore = require("@symfony/webpack-encore"); Encore.setOutputPath("public/dist/") .setPublicPath("/dist") .addEntry("index", "./assets/js/index.js") .cleanupOutputBeforeBuild() .enableSourceMaps(!Encore.isProduction()) .enableVersioning(Encore.isProduction()) .enableSassLoader() .enablePostCssLoader() .enableSingleRuntimeChunk() .createSharedEntry("vendor", “./assets/js/vendor.js"); .autoProvideVariables({ $: "cash-dom", jQuery: "cash-dom" }) module.exports = Encore.getWebpackConfig(); the same thing in encore. multiple entries dev tools dev/prod mode css loading & transformation chunking / splitting global variable shimming all dev tools included automatic manifests / caches
  • 21. living on the edge. I’m using encore 0.21 here. That’s ~134 commits ahead of the documented stable release. Demo
  • 23. .enableVueLoader() npm install vue vue-loader@^15.0.11 vue-template-compiler --save-dev
  • 24. 24 •Webpack 2 -> Webpack 4 •“shared commons entries” -> split chunks plugin •dedicated vendor / client code chunks for entries •“vendors.js & manifest.json” will be replaced with “entrypoints.json” •every page gets exactly what it needs •shared runtime chunk •contains the webpack runtime for all pages •dynamic imports (lazy loading specialized libraries / features) •Handlebars loader built in upcoming in the next release
  • 25. 25 •massively reduces effort to enable modern frontend features •by being highly opinionated •integrates perfectly into Symfony applications •the simplest way to enable modern frontend support •perfect tool to start migrating old frontend code •not so great to start a SPA/PWA/AMP project (use vue.cli or c-r-app instead) •it just generates configuration •you can always add your own config •simple to “down”grade to plain webpack •you can even use it outside a Symfony context •the current release is stable and production ready. •don’t use the bleeding edge master yet!! wrap up
  • 26. Turbine Kreuzberg GmbH Ohlauer Straße 43 10999 Berlin ASSET MANAGEMENT FOR THE REST OF US. @stadolf #turbinejetzt hello@turbinekreuzberg.com https://github.com/elmariachi111/encore-demo