更改资产(css或js)文件后,我在日志中看到已注意到并编译了更改,并且浏览器也自动重新加载。
[debug] Live reload: priv/static/js/app.js
10:53:15 - info: compiled MyComponent.jsx and 2095 cached files into 2
files in 2.3 sec
但是,似乎/priv/static
中的资产并未真正更新。运行mix phx.digest
,并强制刷新浏览器后,我才能在浏览器中看到更改。
有关如何解决此问题的任何想法?
使用:
config / dev.exs:
config :my_app, MyApp.Web.Endpoint,
http: [port: 4000],
debug_errors: true,
code_reloader: true,
check_origin: false,
watchers: [node: ["node_modules/brunch/bin/brunch", "watch", "--stdin",
cd: Path.expand("../assets", __DIR__)]]
# Watch static and templates for browser reloading.
config :my_app, MyApp.Web.Endpoint,
live_reload: [
patterns: [
~r{priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$},
~r{priv/gettext/.*(po)$},
~r{lib/my_app/web/views/.*(ex)$},
~r{lib/my_app/web/templates/.*(eex)$}
]
]
我遇到了同样的问题,对我来说,它有助于手动删除带有static
的rm -rf priv/static
文件夹并使用mix phx.server
重新启动服务器。之后,热重装就可以进行,而不必一直手动运行mix phx.digest
。