File tree 2 files changed +40
-0
lines changed
Filter options
2 files changed +40
-0
lines changed
Original file line number Diff line number Diff line change 58
58
* :doc: `jQuery and Legacy Applications </frontend/encore/legacy-apps >`
59
59
* :doc: `Passing Information from Twig to JavaScript </frontend/encore/server-data >`
60
60
* :doc: `webpack-dev-server and Hot Module Replacement (HMR) </frontend/encore/dev-server >`
61
+ * :doc: `Adding custom loaders </frontend/encore/custom-loaders >`
61
62
62
63
Full API
63
64
........
Original file line number Diff line number Diff line change
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
+ )
You can’t perform that action at this time.
0 commit comments