How to get rid of ^ H when using webpack with iex -S mix phoenix.server?

I am using webpack with phoenix. Many ^H will be output when I use iex -S mix phoenix.server to start the server. Like this

 iex(1)> ^H^H^H^H^H^H^H^H^H^H^H^H 0% compile ^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H 10% 0/1 build modules^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H 70% 1/1 build modules^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H 40% 1/2 build modules^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H 30% 1/3 build modules[bootstrap-sass-loader]: styleLoader: style-loader! css-loader!sass-loader ... 

What is the problem? And how to solve it?

+5
source share
2 answers

This is because I use --progress in my phoenix watchers configuration:

 watchers: [node: ["node_modules/webpack/bin/webpack.js", "--watch", "--colors", "--progress"]] 

Then webpack will output \b to make the move, as the code shows https://github.com/webpack/webpack/blob/master/bin/convert-argv.js#L408 .

Finally, my solution modifies the webpack arguments to support both mix phoenix and iex -S mix phoenix.server :

 webpack_args = ["node_modules/webpack/bin/webpack.js", "--watch", "--colors", "--progress"] # Remove progress argument to make iex display log normally if IEx.started?, do: webpack_args = List.delete(webpack_args, "--progress") config :sample, Sample.Endpoint, # ... watchers: [node: webpack_args] 
+9
source

The reason for this conclusion is the webpack --progress flag, since @ tony-han indicates correctly which is configured as an observer and is running for the Phoenix endpoint in the dev environment.

This and other observers are only started if the :server option is activated. At least in recent versions of Phoenix, this parameter is set to false by default, and it is activated only with the mix phx.server . This means that by default this should not happen in iex at all.

You can check the endpoint configuration of the dev environment to configure server: true , which is not needed. If you delete it, this problem should be resolved.

NB, the server: true parameter (or, alternatively, the more global config :phoenix, :serve_endpoints, true ) should be specified in the prod environment, since this often starts when the release starts.

0
source

Source: https://habr.com/ru/post/1234477/


All Articles