-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Frontend] Add docs for custom loaders #8083
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be javascript |
||
|
||
Encore | ||
// ... | ||
.addLoader( | ||
{ | ||
test: /\.handlebars$/, | ||
loader: 'handlebars-loader', | ||
query: { | ||
helperDirs: [ | ||
__dirname + '/helpers1', | ||
__dirname + '/helpers2', | ||
], | ||
partialDirs: [ | ||
path.join(__dirname, 'templates', 'partials') | ||
] | ||
} | ||
} | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The CS on this isn't quite right yet... |
||
|
||
.. _`handlebars-loader`: https://github.com/pcardune/handlebars-loader |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... out of the box. But if...