Skip to content

Adding note about browserslist config #8054

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

Merged
merged 1 commit into from
Jun 22, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions frontend/encore/postcss.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Next, create a ``postcss.config.js`` file at the root of your project:
plugins: {
// include whatever plugins you want
// but make sure you install these via yarn or npm!

// add browserslist config to package.json (see below)
autoprefixer: {}
}
}
Expand All @@ -35,6 +37,29 @@ Then, Enable the loader in Encore!

That's it! The ``postcss-loader`` will now be used for all CSS, Sass, etc files.

Adding browserslist to package.json
-----------------------------------

The ``autoprefixer`` (and many other tools) need to know what browsers you want to
support. The best-practice is to configure this directly in your ``package.json``
(so that all the tools can read this):

.. code-block:: diff

{
+ "browserslist": [ "last 2 versions", "ios >= 8" ]
}

See `browserslist`_ for more details on the syntax.

.. note::

Encore uses `babel-preset-env`_, which *also* needs to know which browsers you
want to support. But this does *not* read the ``browserslist`` config key. You
must configure the browsers separately via :doc:`configureBabel() </frontend/encore/babel>`.

.. _`PostCSS`: http://postcss.org/
.. _`autoprefixing`: https://github.com/postcss/autoprefixer
.. _`linting`: https://stylelint.io/
.. _`browserslist`: https://github.com/ai/browserslist
.. _`babel-preset-env`: https://github.com/babel/babel-preset-env