Skip to content

Commit 4150430

Browse files
committed
Backport 20755 pull request
1 parent 83940d2 commit 4150430

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

frontend/encore/advanced-config.rst

+28
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,34 @@ Now you can inject your service into your class::
198198
$this->render($emailTwo);
199199
}
200200

201+
Configuring the CSS Loader
202+
--------------------------
203+
204+
Encore provides the ``configureCssLoader()`` method to customize how ``css-loader``
205+
processes your CSS assets. One common use case is to prevent Webpack from resolving
206+
certain URLs.
207+
208+
For instance, if your application serves user-uploaded assets from a specific
209+
directory, you'll want Webpack to ignore these paths since they may not exist
210+
during the build process:
211+
212+
.. code-block:: javascript
213+
214+
// Configuring the CSS Loader in Webpack Encore
215+
// Prevent Webpack from resolving certain URLs in CSS files
216+
Encore.configureCssLoader((options) => {
217+
options.url = {
218+
filter: (url) => {
219+
// Ignore URLs beginning with /uploads/
220+
if (url.startsWith('/uploads/')) {
221+
return false;
222+
}
223+
224+
return true; // Process other URLs as usual
225+
},
226+
};
227+
});
228+
201229
Generating a Webpack Configuration Object without using the Command-Line Interface
202230
----------------------------------------------------------------------------------
203231

0 commit comments

Comments
 (0)