Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3d9905e

Browse filesBrowse files
pierredupweaverryan
authored andcommitted
Add docs for custom loaders
1 parent 7983f69 commit 3d9905e
Copy full SHA for 3d9905e

File tree

2 files changed

+40
-0
lines changed
Filter options

2 files changed

+40
-0
lines changed

‎frontend.rst

Copy file name to clipboardExpand all lines: frontend.rst
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Guides
5858
* :doc:`jQuery and Legacy Applications </frontend/encore/legacy-apps>`
5959
* :doc:`Passing Information from Twig to JavaScript </frontend/encore/server-data>`
6060
* :doc:`webpack-dev-server and Hot Module Replacement (HMR) </frontend/encore/dev-server>`
61+
* :doc:`Adding custom loaders </frontend/encore/custom-loaders>`
6162

6263
Full API
6364
........

‎frontend/encore/custom-loaders.rst

Copy file name to clipboard
+39Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
Adding Custom Loaders
2+
=====================
3+
4+
Encore already comes with a variety of different loaders that you can use out of the box,
5+
but if there is a specific loader that you want to use that is not currently supported, then you
6+
can easily add your own loader through the ``addLoader`` function.
7+
The ``addLoader`` takes any valid webpack rules config.
8+
9+
If, for example, you want to add the `handlebars-loader`_, you can just ``addLoader`` with
10+
your loader config
11+
12+
.. code-block:: javascript
13+
14+
Encore
15+
// ...
16+
.addLoader({ test: /\.handlebars$/, loader: 'handlebars-loader' })
17+
18+
Since the loader config accepts any valid Webpack rules object, you can pass any
19+
additional information your need for the loader
20+
21+
.. code-block:: twig
22+
23+
Encore
24+
// ...
25+
.addLoader(
26+
{
27+
test: /\.handlebars$/,
28+
loader: 'handlebars-loader',
29+
query: {
30+
helperDirs: [
31+
__dirname + '/helpers1',
32+
__dirname + '/helpers2',
33+
],
34+
partialDirs: [
35+
path.join(__dirname, 'templates', 'partials')
36+
]
37+
}
38+
}
39+
)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.