|
| 1 | +Encore Versus Assetic? |
| 2 | +====================== |
| 3 | + |
| 4 | +Symfony originally shipped with support for :doc:`Assetic </assetic>`: a |
| 5 | +pure PHP library capable of processing, combining and minifying CSS and JavaScript |
| 6 | +files. And while Encore is now the recommended way or processing your assets, Assetic |
| 7 | +still works well. |
| 8 | + |
| 9 | +So what are the differences between Assetic and Encore? |
| 10 | + |
| 11 | ++--------------------------+-------------------------------+-------------------------+ |
| 12 | +| | Assetic | Encore + |
| 13 | ++--------------------------+-------------------------------+-------------------------+ |
| 14 | +| Language | Pure PHP, relies on other | Node.js | |
| 15 | +| | language tools for some tasks | | |
| 16 | ++--------------------------+-------------------------------+-------------------------+ |
| 17 | +| Combine assets? | Yes | Yes | |
| 18 | ++--------------------------+-------------------------------+-------------------------+ |
| 19 | +| Minify assets? | Yes (when configured) | Yes (out-of-the-box) | |
| 20 | ++--------------------------+-------------------------------+-------------------------+ |
| 21 | +| Process Sass/Less? | Yes | Yes | |
| 22 | ++--------------------------+-------------------------------+-------------------------+ |
| 23 | +| Loads JS Modules? [1]_ | No | Yes | |
| 24 | ++--------------------------+-------------------------------+-------------------------+ |
| 25 | +| Load CSS Deps in JS? [1] | No | Yes | |
| 26 | ++--------------------------+-------------------------------+-------------------------+ |
| 27 | +| React, Vue.js support? | No [2]_ | Yes | |
| 28 | ++--------------------------+-------------------------------+-------------------------+ |
| 29 | +| Support | Not actively maintained | Actively maintained | |
| 30 | ++--------------------------+-------------------------------+-------------------------+ |
| 31 | + |
| 32 | +.. [1] JavaScript modules allow you to organize your JavaScript into small files |
| 33 | + called modules and import them: |
| 34 | +
|
| 35 | + .. code-block:: javascript |
| 36 | +
|
| 37 | + // require third-party modules |
| 38 | + var $ = require('jquery'); |
| 39 | +
|
| 40 | + // require your own CoolComponent.js modules |
| 41 | + var coolComponent = require('./components/CoolComponent'); |
| 42 | +
|
| 43 | + Encore (via Webpack) parses these automatically and creates a JavaScript |
| 44 | + file that contains all needed dependencies. You can even require CSS or |
| 45 | + images. |
| 46 | +
|
| 47 | +.. [2] Assetic has outdated support for React.js only. Encore ships with modern |
| 48 | + support for React.js, Vue.js, Typescript, etc. |
| 49 | +
|
| 50 | +Should I Upgrade from Assetic to Encore |
| 51 | +--------------------------------------- |
| 52 | + |
| 53 | +If you already have Assetic working in an application, and haven't needed any of |
| 54 | +the features that Encore offers over Assetic, continuting to use Assetic is fine. |
| 55 | +If you *do* start to need more features, then you might have a business case for |
| 56 | +changing to Encore. |
0 commit comments