Webpack Encore*
Asset management for the rest of us
*by symfony
The frontend frontier
“Javascript”
No native package system
Many flavors, many frameworks
ECMAScript 6/7, TypeScript, CommonJS
jQuery, React (JSX), Angular, Meteor
“Styles”
Lots of quirks, lots of frameworks
LESS, Sass & Scss
PostCss, Autoprefixer, Reboots, (Compass)
In the end it boils
down to this:
Where we come from
<script src=“js/jquery.js”></script>

<script src=“js/mootools.js”></script>

<script src=“js/app.js”></script>
requirejs([‘jquery'], function( $ ) {
console.log( $ );
});
var unique = require('uniq');
var data = [2, 2, 3, 4, 5, 5, 5, 6];
console.log(unique(data));
Where we want to go
Where we are.
Webpack
Setting up module “bundling” == no-brainer
Everything is based on Javascript
Import scss, images, xml, templates
Webpack loaders: transforming
LOTS of plugins and loaders
Highly configurable
Used by all major modern JS app frameworks
angular, vuejs, react, ionic
Plain Webpack
Gist
Repo Read Along
Include npm libraries
Babelify es6/7
Globals 

supported
Include styles
Include npm librariesExtracts css assets
Tooling & versioning

included
Where we are :/
WHAT IF I TOLD YOU
THAT WEBPACK CONFIGURATION

DOESN’T HAVE TO SUCK?
Where we are :/
Webpack Encore
“Symfony” by name, JavaScript at heart
Just a layer on top of webpack
Replaces assetic bundle (dumped in 3.0)
Opinionated “recipes” how fullstack
developers build assets.
Support for many modern features and
frameworks out of the box.
npm install

@symfony/webpack-encore
——save-dev
https://symfony.com/blog/introducing-
webpack-encore-for-asset-management
http://symfony.com/doc/current/
frontend.html
Meaningful error messages

and installation hints
You can still use Webpack
plugins if you need them
Add react.js
npm install --save-dev react react-dom prop-types
babel-preset-react
Symfony integration (3.3)
framework:
assets:
base_path: "/dist"
json_manifest_path: "%kernel.project_dir%/web/
dist/manifest.json"
manifest.json
base.html.twig
config.yml
SORRY, NO
ENCORE HERE.
Stefan Adolf

https://www.facebook.com/stadolf

https://twitter.com/stadolf

https://github.com/elmariachi111

https://www.linkedin.com/in/stadolf/
I am
https://github.com/elmariachi111/encore-demo/pulls
https://gist.github.com/elmariachi111/f250c9d96280082e5c4f0abfd9fd6ede

OUTDATED (Encore)