8000 Adding docs about adding custom config - see #8067 · symfony/symfony-docs@62dd63e · GitHub
[go: up one dir, main page]

Skip to content

Commit 62dd63e

Browse files
committed
Adding docs about adding custom config - see #8067
1 parent 0ff1c3c commit 62dd63e

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

frontend.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Guides
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>`
6161
* :doc:`Adding custom loaders </frontend/encore/custom-loaders>`
62+
* :doc:`Advanced Webpack Configuration </frontend/encore/advanced-config>`
6263

6364
Full API
6465
........

frontend/encore/advanced-config.rst

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
Advanced Webpack Config
2+
=======================
3+
4+
Quite simply, Encore generates the Webpack configuration that's used in your
5+
``webpack.config.js`` file. Encore doesn't support adding all of Webpack's
6+
`configuration options`_, because many can be easy added on your own.
7+
8+
For example, suppose you need to set `Webpack's watchOptions`_ setting. To do that,
9+
modify the config it after fetching the it from Encore:
10+
11+
.. code-block:: javascript
12+
13+
// webpack.config.js
14+
15+
var Encore = require('@symfony/webpack-encore');
16+
17+
// ... all Encore config here
18+
19+
// fetch the config, then modify it!
20+
var config = Encore.getWebpackConfig();
21+
config.watchOptions = { poll: true, ignored: /node_modules/ };
22+
23+
// other examples: add an alias or extension
24+
// config.resolve.alias.local = path.resolve(__dirname, './resources/src');
25+
// config.resolve.extensions.push('json');
26+
27+
28+
// export the final config
29+
module.exports = config;
30+
31+
But be careful not to accidentally override any config from Encore:
32+
33+
.. code-block:: javascript
34+
35+
// webpack.config.js
36+
// ...
37+
38+
// GOOD - this modifies the config.resolve.extensions array
39+
// config.resolve.extensions.push('json');
40+
41+
// BAD - this replaces any extensions added by Encore
42+
// config.resolve.extensions = ['json'];
43+
44+
.. _`configuration options`: https://webpack.js.org/configuration/
45+
.. _`Webpack's watchOptions`: https://webpack.js.org/configuration/watch/#watchoptions

0 commit comments

Comments
 (0)
0