8000 Various Encore updates by weaverryan · Pull Request #8084 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

Various Encore updates #8084

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 10 commits into from
Jun 26, 2017
Next Next commit
Add docs for custom loaders
  • Loading branch information
pierredup authored and weaverryan committed Jun 25, 2017
commit 3d9905e093925ba681810a5891c5f5c25f35db2d
1 change: 1 addition & 0 deletions frontend.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Guides
* :doc:`jQuery and Legacy Applications </frontend/encore/legacy-apps>`
* :doc:`Passing Information from Twig to JavaScript </frontend/encore/server-data>`
* :doc:`webpack-dev-server and Hot Module Replacement (HMR) </frontend/encore/dev-server>`
* :doc:`Adding custom loaders </frontend/encore/custom-loaders>`

Full API
........
Expand Down
39 changes: 39 additions & 0 deletions frontend/encore/custom-loaders.rst
3D3A
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Adding Custom Loaders
=====================

Encore already comes with a variety of different loaders that you can use out of the box,
but if there is a specific loader that you want to use that is not currently supported, then you
can easily add your own loader through the ``addLoader`` function.
The ``addLoader`` takes any valid webpack rules config.

If, for example, you want to add the `handlebars-loader`_, you can just ``addLoader`` with
your loader config

.. code-block:: javascript

Encore
// ...
.addLoader({ test: /\.handlebars$/, loader: 'handlebars-loader' })

Since the loader config accepts any valid Webpack rules object, you can pass any
additional information your need for the loader

.. code-block:: twig

Encore
// ...
.addLoader(
{
test: /\.handlebars$/,
loader: 'handlebars-loader',
query: {
helperDirs: [
__dirname + '/helpers1',
__dirname + '/helpers2',
],
partialDirs: [
path.join(__dirname, 'templates', 'partials')
]
}
}
)
0