Skip to content

Hello AssetMapper Documentation #18370

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 14 commits into from
75 changes: 58 additions & 17 deletions frontend.rst
Original file line number Diff line number Diff line change
@@ -1,21 +1,44 @@
Managing CSS and JavaScript
===========================

.. admonition:: Screencast
:class: screencast

Do you prefer video tutorials? Check out the `Webpack Encore screencast series`_.

Symfony ships with a pure-JavaScript library - called Webpack Encore - that makes
it a joy to work with CSS and JavaScript. You can use it, use something else, or
create static CSS and JS files in your ``public/`` directory directly and
include them in your templates.
Symfony Frontend Tools
======================
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This document is now a bit more important than before. On https://symfony.com/doc/current/index.html, I don't think we link to it at all. After we merge this, we probably should.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Webpack Encore" is linking to it. We should probably do the same as with Security and call it "Introduction"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. I added some TODO to the PR description for post-merge changes to the main documentation page.


Symfony ships with two different options for handling the CSS and JavaScript in
your app:

* :ref:`Webpack Encore <frontend-webpack-encore>` is a powerful tool build with Node
on top of `Webpack`_ that allows you to write modern CSS & JavaScript and handle
things like JSX (React), Vur or TypeScript. It's the recommended option for
new Symfony apps.

* :ref:`Asset Mapper <frontend-asset-mapper>`, is a production-ready simpler alternative
to Webpack Encore that runs entirely in PHP. It's currently experimental.

Overall, `Asset Mapper` is powerful & simpler, but doesn't support certain
features like JSX or TypeScript:

========================================= ================= =================
Encore AssetMapper
========================================= ================= =================
Production Ready? yes yes
Stable? yes experimental
Requirements node none: pure PHP
Requires a build step? yes no
Works in all browsers? yes yes
Supports :doc:`Stimulus/UX </frontend/ux>` yes yes
Supports Sass/Tailwind yes :ref:`yes <asset-mapper-extras>`
Supports JSX, Vue? yes no
Supports TypeScript yes no
========================================= ================= =================

.. _frontend-webpack-encore:

Webpack Encore
--------------

.. admonition:: Screencast
:class: screencast

Do you prefer video tutorials? Check out the `Webpack Encore screencast series`_.

`Webpack Encore`_ is a simpler way to integrate `Webpack`_ into your application.
It *wraps* Webpack, giving you a clean & powerful API for bundling JavaScript modules,
pre-processing CSS & JS and compiling and minifying assets. Encore gives you professional
Expand Down Expand Up @@ -84,26 +107,44 @@ Full API

* `Full API`_

.. _frontend-asset-mapper:

Asset Mapper
------------

Asset Mapper is an alternative to Webpack Encore that runs entirely in PHP
without any complex build steps. It leverages the ``importmap`` feature of
your browser, which is available in all browsers thanks to a polyfill.
Asset Mapper is currently experimental.

* :doc:`Install AssetMapper </frontend/asset_mapper/installation>`
* :doc:`Using AssetMapper </frontend/asset_mapper/usage>`
* :doc:`Handling CSS </frontend/asset_mapper/css>`
* :doc:`FAQ & Common Issues </frontend/asset_mapper/faq>`

Symfony UX Components
---------------------

* :doc:`/frontend/ux`

.. include:: /frontend/_ux-libraries.rst.inc

Other Front-End Articles
------------------------

* :doc:`/frontend/create_ux_bundle`
* :doc:`/frontend/custom_version_strategy`

.. toctree::
:hidden:
:glob:

frontend/encore/installation
frontend/encore/simple-example
frontend/encore/*

.. toctree::
:maxdepth: 1
:glob:

frontend/asset_mapper/installation
frontend/asset_mapper/usage
frontend/asset_mapper/*
frontend/*
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bottom of https://symfony.com/doc/current/frontend.html is currently "wonky". I think the intention was for the the first, :hidden toctree to "load" all of the encore stuff into the toctree... and then this bottom toctree would only load anything "remaining". In practice, it would render everything.

So, I reduced this to just ONE toctree, which is :hidden:. The 2 documents that are outside of encore/* were added manually under the Other Front-End Articles section.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fun fact, including documents in a toctree entry is no longer relevant with the PHP based parser IIRC

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That IS a fun fact, thank you!


.. _`Webpack Encore`: https://www.npmjs.com/package/@symfony/webpack-encore
Expand Down
Loading