Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to restart Encore after making changes to webpack.config.js

I'm using Symfony with Encore and after reading through this article, it says to restart encore after making changes but I can't find the command to do so. I tried setting up nodemon to watch webpack.config.js and it throws an error

yarn run v1.9.4
$ nodemon --watch webpack.config.js ./node_modules/.bin/webpack-dev-server
[33m[nodemon] 1.18.3[39m
[33m[nodemon] to restart at any time, enter `rs`[39m
[33m[nodemon] watching: webpack.config.js[39m
[32m[nodemon] starting `node ./node_modules/.bin/webpack-dev-server`[39m
[31m[nodemon] app crashed - waiting for file changes before starting...[39m

and

throw new Error(`Encore.${prop}() 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.`);

I feel like there's a simple command I'm missing but I can't seem to find it. This is what I'm using in package.json

   "start": "nodemon --watch webpack.config.js ./node_modules/.bin/webpack-dev-server",
like image 330
Dan185 Avatar asked Sep 05 '25 13:09

Dan185


2 Answers

If you have the watcher watching your files you just have to terminate that process and then run the watch command again:

yarn encore dev --watch

like image 83
Chip Dean Avatar answered Sep 10 '25 04:09

Chip Dean


Extra tip on Chip Dean's answer: To 'terminate' the running process of encore dev --watch, you'll need to ctrl+c

like image 25
Glenn Avatar answered Sep 10 '25 06:09

Glenn