You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
+
constEncore=require('@symfony/webpack-encore');
125
+
126
+
// Set the runtime environment
127
+
Encore.configureRuntimeEnvironment('dev');
128
+
129
+
// Retrieve the Webpack configuration object
130
+
constwebpackConfig=require('./webpack.config');
131
+
132
+
If needed, you can also pass to that method all the options that you would
0 commit comments