Skip to content

Commit 19fe210

Browse files
committed
Merge branch '4.1'
* 4.1: [Encore] Fixed code example for SplitChunks Fixing type Remove beta command since skeleton isn't tagged [Encore] Add a section about the configureRuntimeEnvironment method
2 parents 2ebb3d5 + 4a747e8 commit 19fe210

File tree

4 files changed

+51
-7
lines changed

4 files changed

+51
-7
lines changed

components/finder.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ the Finder instance.
5151

5252
.. tip::
5353

54-
A Finder instance is a PHP :phpclass:`Iterator`. So, in addition to iterating over the
54+
A Finder instance is a PHP :phpclass:`IteratorAggregate`. So, in addition to iterating over the
5555
Finder with ``foreach``, you can also convert it to an array with the
56-
:phpfunction:`iterator_to_array` method, or get the number of items with
56+
:phpfunction:`iterator_to_array` function, or get the number of items with
5757
:phpfunction:`iterator_count`.
5858

5959
.. caution::

frontend/encore/advanced-config.rst

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,53 @@ prefer to build configs separately, pass the ``--config-name`` option:
9595
9696
$ yarn encore dev --config-name firstConfig
9797
98+
Generating a Webpack Configuration Object without using the Command-Line Interface
99+
----------------------------------------------------------------------------------
100+
101+
Ordinarily you would use your ``webpack.config.js`` file by calling Encore
102+
from the command-line interface. But sometimes, having access to the generated
103+
Webpack configuration can be required by tools that don't use Encore (for
104+
instance a test-runner such as `Karma`_).
105+
106+
The problem is that if you try generating that Webpack configuration object
107+
without using the ``encore`` command you will encounter the following error:
108+
109+
.. code-block:: text
110+
111+
Error: Encore.setOutputPath() cannot be called yet because the runtime environment doesn't appear to be configured. Make sure you're using the encore executable or call Encore.configureRuntimeEnvironment() first if you're purposely not calling Encore directly.
112+
113+
The reason behind that message is that Encore needs to know a few thing before
114+
being able to create a configuration object, the most important one being what
115+
the target environment is.
116+
117+
To solve this issue you can use ``configureRuntimeEnvironment``. This method
118+
must be called from a JavaScript file **before** requiring ``webpack.config.js``.
119+
120+
For instance:
121+
122+
.. code-block:: javascript
123+
124+
const Encore = require('@symfony/webpack-encore');
125+
126+
// Set the runtime environment
127+
Encore.configureRuntimeEnvironment('dev');
128+
129+
// Retrieve the Webpack configuration object
130+
const webpackConfig = require('./webpack.config');
131+
132+
If needed, you can also pass to that method all the options that you would
133+
normally use from the command-line interface:
134+
135+
.. code-block:: javascript
136+
137+
Encore.configureRuntimeEnvironment('dev-server', {
138+
// Same options you would use with the
139+
// CLI utility, with their name in camelCase.
140+
https: true,
141+
keepPublicPath: true,
142+
});
143+
98144
.. _`configuration options`: https://webpack.js.org/configuration/
99145
.. _`Webpack's watchOptions`: https://webpack.js.org/configuration/watch/#watchoptions
100146
.. _`array of configurations`: https://github.com/webpack/docs/wiki/configuration#multiple-configurations
147+
.. _`Karma`: https://karma-runner.github.io

frontend/encore/split-chunks.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ this plugin with the ``configureSplitChunks()`` function:
5959
+ .configureSplitChunks(function(splitChunks) {
6060
+ // change the configuration
6161
+ splitChunks.minSize = 0;
62-
+ }
62+
+ })
6363
6464
.. _`SplitChunksPlugin from Webpack`: https://webpack.js.org/plugins/split-chunks-plugin/

setup/unstable_versions.rst

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ execute the following command:
1414

1515
.. code-block:: terminal
1616
17-
# Download the latest beta version
18-
$ composer create-project symfony/skeleton my_project "4.0.*" -s beta
19-
2017
# Download the absolute latest commit
21-
$ composer create-project symfony/skeleton my_project "4.0.*" -s dev
18+
$ composer create-project symfony/skeleton my_project -s dev
2219
2320
Once the command finishes its execution, you'll have a new Symfony project created
2421
in the ``my_project/`` directory.

0 commit comments

Comments
 (0)