SlideShare une entreprise Scribd logo
1  sur  26
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

RESTful Web Applications with Apache Sling
RESTful Web Applications with Apache SlingRESTful Web Applications with Apache Sling
RESTful Web Applications with Apache SlingBertrand Delacretaz
 
Bundle your modules with Webpack
Bundle your modules with WebpackBundle your modules with Webpack
Bundle your modules with WebpackJake Peyser
 
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST APIWordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST APIBrian Hogg
 
Improving build solutions dependency management with webpack
Improving build solutions  dependency management with webpackImproving build solutions  dependency management with webpack
Improving build solutions dependency management with webpackNodeXperts
 
Advanced front-end automation with npm scripts
Advanced front-end automation with npm scriptsAdvanced front-end automation with npm scripts
Advanced front-end automation with npm scriptsk88hudson
 
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...Alexander Lisachenko
 
Packing for the Web with Webpack
Packing for the Web with WebpackPacking for the Web with Webpack
Packing for the Web with WebpackThiago Temple
 
Native-Javascript Bridging Using WKWebViews in iOS8
Native-Javascript Bridging Using WKWebViews in iOS8Native-Javascript Bridging Using WKWebViews in iOS8
Native-Javascript Bridging Using WKWebViews in iOS8Priya Rajagopal
 
Webpack
Webpack Webpack
Webpack DataArt
 
FITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript DebuggingFITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript DebuggingRami Sayar
 
WKWebView in Production
WKWebView in ProductionWKWebView in Production
WKWebView in ProductionJeremy Wiebe
 
Vue 淺談前端建置工具
Vue 淺談前端建置工具Vue 淺談前端建置工具
Vue 淺談前端建置工具andyyou
 
Webpack and Web Performance Optimization
Webpack and Web Performance OptimizationWebpack and Web Performance Optimization
Webpack and Web Performance OptimizationChen-Tien Tsai
 
Grunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous IntegrationGrunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous IntegrationDavid Amend
 
Sails.js Model / ORM introduce
Sails.js Model / ORM introduceSails.js Model / ORM introduce
Sails.js Model / ORM introduce謝 宗穎
 

Tendances (20)

Webpack slides
Webpack slidesWebpack slides
Webpack slides
 
RESTful Web Applications with Apache Sling
RESTful Web Applications with Apache SlingRESTful Web Applications with Apache Sling
RESTful Web Applications with Apache Sling
 
Bundle your modules with Webpack
Bundle your modules with WebpackBundle your modules with Webpack
Bundle your modules with Webpack
 
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST APIWordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
 
Improving build solutions dependency management with webpack
Improving build solutions  dependency management with webpackImproving build solutions  dependency management with webpack
Improving build solutions dependency management with webpack
 
Advanced front-end automation with npm scripts
Advanced front-end automation with npm scriptsAdvanced front-end automation with npm scripts
Advanced front-end automation with npm scripts
 
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
 
Webpack: from 0 to 2
Webpack: from 0 to 2Webpack: from 0 to 2
Webpack: from 0 to 2
 
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
 
Native-Javascript Bridging Using WKWebViews in iOS8
Native-Javascript Bridging Using WKWebViews in iOS8Native-Javascript Bridging Using WKWebViews in iOS8
Native-Javascript Bridging Using WKWebViews in iOS8
 
Webpack
Webpack Webpack
Webpack
 
FITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript DebuggingFITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript Debugging
 
WKWebView in Production
WKWebView in ProductionWKWebView in Production
WKWebView in Production
 
Vue 淺談前端建置工具
Vue 淺談前端建置工具Vue 淺談前端建置工具
Vue 淺談前端建置工具
 
Webpack and Web Performance Optimization
Webpack and Web Performance OptimizationWebpack and Web Performance Optimization
Webpack and Web Performance Optimization
 
Hey webpack
Hey webpackHey webpack
Hey webpack
 
Grunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous IntegrationGrunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous Integration
 
Sails.js Model / ORM introduce
Sails.js Model / ORM introduceSails.js Model / ORM introduce
Sails.js Model / ORM introduce
 
Sails js
Sails jsSails js
Sails js
 

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

Symfony Live 2018 - Développez votre frontend avec ReactJS et Symfony Webpack...
Symfony Live 2018 - Développez votre frontend avec ReactJS et Symfony Webpack...Symfony Live 2018 - Développez votre frontend avec ReactJS et Symfony Webpack...
Symfony Live 2018 - Développez votre frontend avec ReactJS et Symfony Webpack...Alain Hippolyte
 
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Ran Mizrahi
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Ran Mizrahi
 
Everything-as-code. A polyglot adventure. #DevoxxPL
Everything-as-code. A polyglot adventure. #DevoxxPLEverything-as-code. A polyglot adventure. #DevoxxPL
Everything-as-code. A polyglot adventure. #DevoxxPLMario-Leander Reimer
 
Everything-as-code - A polyglot adventure
Everything-as-code - A polyglot adventureEverything-as-code - A polyglot adventure
Everything-as-code - A polyglot adventureQAware GmbH
 
Introduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureIntroduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureColin Mackay
 
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Codemotion
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVCAlive Kuo
 
JS & NodeJS - An Introduction
JS & NodeJS - An IntroductionJS & NodeJS - An Introduction
JS & NodeJS - An IntroductionNirvanic Labs
 
Introduction to web application development with Vue (for absolute beginners)...
Introduction to web application development with Vue (for absolute beginners)...Introduction to web application development with Vue (for absolute beginners)...
Introduction to web application development with Vue (for absolute beginners)...Lucas Jellema
 
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...tdc-globalcode
 
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...Ryan Weaver
 
SenchaCon 2016: The Modern Toolchain - Ross Gerbasi
SenchaCon 2016: The Modern Toolchain - Ross Gerbasi   SenchaCon 2016: The Modern Toolchain - Ross Gerbasi
SenchaCon 2016: The Modern Toolchain - Ross Gerbasi Sencha
 

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

Symfony Live 2018 - Développez votre frontend avec ReactJS et Symfony Webpack...
Symfony Live 2018 - Développez votre frontend avec ReactJS et Symfony Webpack...Symfony Live 2018 - Développez votre frontend avec ReactJS et Symfony Webpack...
Symfony Live 2018 - Développez votre frontend avec ReactJS et Symfony Webpack...
 
Nodejs web,db,hosting
Nodejs web,db,hostingNodejs web,db,hosting
Nodejs web,db,hosting
 
WebAssemlby vs JavaScript
WebAssemlby vs JavaScriptWebAssemlby vs JavaScript
WebAssemlby vs JavaScript
 
Play framework
Play frameworkPlay framework
Play framework
 
Always on! Or not?
Always on! Or not?Always on! Or not?
Always on! Or not?
 
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)
 
Sanjeev ghai 12
Sanjeev ghai 12Sanjeev ghai 12
Sanjeev ghai 12
 
Everything-as-code. A polyglot adventure. #DevoxxPL
Everything-as-code. A polyglot adventure. #DevoxxPLEverything-as-code. A polyglot adventure. #DevoxxPL
Everything-as-code. A polyglot adventure. #DevoxxPL
 
Everything-as-code - A polyglot adventure
Everything-as-code - A polyglot adventureEverything-as-code - A polyglot adventure
Everything-as-code - A polyglot adventure
 
Introduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureIntroduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azure
 
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
 
Full Stack Scala
Full Stack ScalaFull Stack Scala
Full Stack Scala
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
 
JS & NodeJS - An Introduction
JS & NodeJS - An IntroductionJS & NodeJS - An Introduction
JS & NodeJS - An Introduction
 
Npm scripts
Npm scriptsNpm scripts
Npm scripts
 
Introduction to web application development with Vue (for absolute beginners)...
Introduction to web application development with Vue (for absolute beginners)...Introduction to web application development with Vue (for absolute beginners)...
Introduction to web application development with Vue (for absolute beginners)...
 
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
 
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
 
SenchaCon 2016: The Modern Toolchain - Ross Gerbasi
SenchaCon 2016: The Modern Toolchain - Ross Gerbasi   SenchaCon 2016: The Modern Toolchain - Ross Gerbasi
SenchaCon 2016: The Modern Toolchain - Ross Gerbasi
 

Plus de Stefan Adolf

Blockchains - Technical foundations
Blockchains - Technical foundationsBlockchains - Technical foundations
Blockchains - Technical foundationsStefan Adolf
 
HOW TO SURVIVE A 2DAY HACKATHON?
HOW TO SURVIVE A 2DAY HACKATHON?HOW TO SURVIVE A 2DAY HACKATHON?
HOW TO SURVIVE A 2DAY HACKATHON?Stefan Adolf
 
Digitale Selbstbestimmung mit Hilfe dezentraler Technologien
Digitale Selbstbestimmung mit Hilfe dezentraler TechnologienDigitale Selbstbestimmung mit Hilfe dezentraler Technologien
Digitale Selbstbestimmung mit Hilfe dezentraler TechnologienStefan Adolf
 
Digitale Selbstbestimmung | Anwendungsfälle der Dezentralität
Digitale Selbstbestimmung | Anwendungsfälle der DezentralitätDigitale Selbstbestimmung | Anwendungsfälle der Dezentralität
Digitale Selbstbestimmung | Anwendungsfälle der DezentralitätStefan Adolf
 
Decentralized technology: a (short) survey
Decentralized technology: a (short) surveyDecentralized technology: a (short) survey
Decentralized technology: a (short) surveyStefan Adolf
 
Productive web applications that run only on the frontend
Productive web applications that run only on the frontendProductive web applications that run only on the frontend
Productive web applications that run only on the frontendStefan Adolf
 
DePA - die dezentrale Patientenakte (29.1. FU Berlin)
DePA - die dezentrale Patientenakte (29.1. FU Berlin)DePA - die dezentrale Patientenakte (29.1. FU Berlin)
DePA - die dezentrale Patientenakte (29.1. FU Berlin)Stefan Adolf
 
DePA - die dezentrale Patientenakte
DePA - die dezentrale PatientenakteDePA - die dezentrale Patientenakte
DePA - die dezentrale PatientenakteStefan Adolf
 
Was ist eine Datenbank - und was hat Blockchain damit zu tun?
Was ist eine Datenbank - und was hat Blockchain damit zu tun?Was ist eine Datenbank - und was hat Blockchain damit zu tun?
Was ist eine Datenbank - und was hat Blockchain damit zu tun?Stefan Adolf
 
Never Code Alone: Von Symfony Forms zu einer SPA auf APIs
Never Code Alone: Von Symfony Forms zu einer SPA auf APIsNever Code Alone: Von Symfony Forms zu einer SPA auf APIs
Never Code Alone: Von Symfony Forms zu einer SPA auf APIsStefan Adolf
 
Decentralize all the things
Decentralize all the thingsDecentralize all the things
Decentralize all the thingsStefan Adolf
 
Indexing Decentralized Data with Ethereum, IPFS & The Graph
Indexing Decentralized Data with Ethereum, IPFS & The GraphIndexing Decentralized Data with Ethereum, IPFS & The Graph
Indexing Decentralized Data with Ethereum, IPFS & The GraphStefan Adolf
 
Gatsby (Code.Talks) 2019
Gatsby (Code.Talks) 2019Gatsby (Code.Talks) 2019
Gatsby (Code.Talks) 2019Stefan Adolf
 
A micro service story
 A micro service story A micro service story
A micro service storyStefan Adolf
 
Api Platform: the ultimate API Platform
Api Platform: the ultimate API PlatformApi Platform: the ultimate API Platform
Api Platform: the ultimate API PlatformStefan Adolf
 
Pump up the JAM with Gatsby (2019)
Pump up the JAM with Gatsby (2019)Pump up the JAM with Gatsby (2019)
Pump up the JAM with Gatsby (2019)Stefan Adolf
 
Testing API platform with Behat BDD tests
Testing API platform with Behat BDD testsTesting API platform with Behat BDD tests
Testing API platform with Behat BDD testsStefan Adolf
 
Hack it like its hot!
Hack it like its hot!Hack it like its hot!
Hack it like its hot!Stefan Adolf
 
api-platform: the ultimate API platform
api-platform: the ultimate API platformapi-platform: the ultimate API platform
api-platform: the ultimate API platformStefan Adolf
 
Pump up the JAM with Gatsby
Pump up the JAM with GatsbyPump up the JAM with Gatsby
Pump up the JAM with GatsbyStefan Adolf
 

Plus de Stefan Adolf (20)

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

Dernier

Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 

Dernier (20)

Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 

(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