I use 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's the problem? And how to solve it?
It's because I use --progress
in the my phoenix watchers config:
watchers: [node: ["node_modules/webpack/bin/webpack.js", "--watch", "--colors",
"--progress"]]
Then webpack will output \b
to make a progress as the code shows https://github.com/webpack/webpack/blob/master/bin/convert-argv.js#L408.
Finally, my solution is changing 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]
The cause of this output is the webpack --progress
flag, as @tony-han points out correctly, which is configured as a watcher and started for the Phoenix endpoint in dev
environment.
This and other watchers are run only, if the option :server
is activated. At least in recent Phoenix versions this setting is set to false
by default, and it's only activated by the mix phx.server
task. That means by default this shouldn't happen in iex
at all.
You can check your dev
environment's endpoint configuration for a setting server: true
, which is unnecessary. If you remove it, this problem should be resolved.
NB, the server: true
setting (or alternatively the more global config :phoenix, :serve_endpoints, true
) should given in prod
environment, as this is often started by running a release.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With