|
1 | | -Managing CSS and JavaScript |
2 | | -=========================== |
3 | | - |
4 | | -..admonition::Screencast |
5 | | -:class: screencast |
6 | | - |
7 | | - Do you prefer video tutorials? Check out the `Webpack Encore screencast series`_. |
8 | | - |
9 | | -Symfony ships with a pure-JavaScript library - called Webpack Encore - that makes |
10 | | -it a joy to work with CSS and JavaScript. You can use it, use something else, or |
11 | | -create static CSS and JS files in your ``public/`` directory directly and |
12 | | -include them in your templates. |
| 1 | +Introduction |
| 2 | +============ |
| 3 | + |
| 4 | +Symfony gives you the flexibility to choose any front-end tools you want. This could |
| 5 | +be dead-simple - like putting CSS & JS directly in the ``public/`` directory - or |
| 6 | +more advanced - like scaffolding your front-end with a tool like Next.js. |
| 7 | + |
| 8 | +However, Symfony *does* come with two powerful option to help you build a modern, |
| 9 | +fast frontend, *and* enjoy the process: |
| 10 | + |
| 11 | +*:ref:`Webpack Encore<frontend-webpack-encore>` is a powerful tool built with Node |
| 12 | + on top of `Webpack`_ that allows you to write modern CSS & JavaScript and handle |
| 13 | + things like JSX (React), Vue or TypeScript. |
| 14 | + |
| 15 | +*:ref:`AssetMapper<frontend-asset-mapper>`, is a production-ready simpler alternative |
| 16 | + to Webpack Encore that runs entirely in PHP. It's currently experimental. |
| 17 | + |
| 18 | +========================================== ================= ====================================================== |
| 19 | + Encore AssetMapper |
| 20 | +========================================== ================= ====================================================== |
| 21 | +Production Ready? yes yes |
| 22 | +Stable? yes:doc:`experimental</contributing/code/experimental>` |
| 23 | +Requirements node none: pure PHP |
| 24 | +Requires a build step? yes no |
| 25 | +Works in all browsers? yes yes |
| 26 | +Supports:doc:`Stimulus/UX</frontend/ux>` yes yes |
| 27 | +Supports Sass/Tailwind yes:ref:`yes<asset-mapper-tailwind>` |
| 28 | +Supports React, Vue, Svelte? yes yes** |
| 29 | +Supports TypeScript yes no** |
| 30 | +========================================== ================= ====================================================== |
| 31 | + |
| 32 | +** Using JSX (React), Vue or TypeScript with AssetMapper is possible, but you'll |
| 33 | + need to use their native tools for pre-compilation. Also, some features (like |
| 34 | + Vue single-file components) cannot be compiled down to pure JavaScript that can |
| 35 | + be executed by a browser. |
13 | 36 |
|
14 | 37 | .. _frontend-webpack-encore: |
15 | 38 |
|
16 | 39 | Webpack Encore |
17 | 40 | -------------- |
18 | 41 |
|
| 42 | +..screencast:: |
| 43 | + |
| 44 | + Do you prefer video tutorials? Check out the `Webpack Encore screencast series`_. |
| 45 | + |
19 | 46 | `Webpack Encore`_ is a simpler way to integrate `Webpack`_ into your application. |
20 | 47 | It *wraps* Webpack, giving you a clean & powerful API for bundling JavaScript modules, |
21 | 48 | pre-processing CSS & JS and compiling and minifying assets. Encore gives you professional |
@@ -84,26 +111,39 @@ Full API |
84 | 111 |
|
85 | 112 | * `Full API`_ |
86 | 113 |
|
| 114 | +.. _frontend-asset-mapper: |
| 115 | + |
| 116 | +AssetMapper |
| 117 | +----------- |
| 118 | + |
| 119 | +AssetMapper is an alternative to Webpack Encore that runs entirely in PHP |
| 120 | +without any complex build steps. It leverages the ``importmap`` feature of |
| 121 | +your browser, which is available in all browsers thanks to a polyfill. |
| 122 | +AssetMapper is currently:doc:`experimental</contributing/code/experimental>`. |
| 123 | + |
| 124 | +:doc:`Read the AssetMapper Documentation</frontend/asset_mapper>` |
| 125 | + |
87 | 126 | Symfony UX Components |
88 | 127 | --------------------- |
89 | 128 |
|
| 129 | +*:doc:`/frontend/ux` |
| 130 | + |
90 | 131 | ..include::/frontend/_ux-libraries.rst.inc |
91 | 132 |
|
92 | 133 | Other Front-End Articles |
93 | 134 | ------------------------ |
94 | 135 |
|
| 136 | +*:doc:`/frontend/create_ux_bundle` |
| 137 | +*:doc:`/frontend/custom_version_strategy` |
| 138 | + |
95 | 139 | ..toctree:: |
96 | 140 | :hidden: |
97 | 141 | :glob: |
98 | 142 |
|
99 | 143 | frontend/encore/installation |
100 | 144 | frontend/encore/simple-example |
101 | 145 | frontend/encore/* |
102 | | - |
103 | | -..toctree:: |
104 | | -:maxdepth:1 |
105 | | -:glob: |
106 | | - |
| 146 | +frontend/asset_mapper |
107 | 147 | frontend/* |
108 | 148 |
|
109 | 149 | .. _`Webpack Encore`:https://www.npmjs.com/package/@symfony/webpack-encore |
|