sass-brunch 在实时重新加载时忽略修改后的 SCSS

sass-brunch omits modified SCSS on live-reload

在我的 Phoenix 项目中,我发现 sass-brunch.

的一个特殊行为

以下是我的问题的简短描述:

在日志文件中,我注意到可能与此问题相关的条目:

[debug] Duplicate channel join for topic "phoenix:live_reload" in Phoenix.LiveReloader.Socket. Closing existing channel for new join.

我在 Mac 上没有看到这样的一行。

我的环境:

我的package.json:

{ "repository": {}, "license": "MIT", "scripts": { "deploy": "brunch build --production", "watch": "brunch watch --stdin" }, "dependencies": { "phoenix": "file:deps/phoenix", "phoenix_html": "file:deps/phoenix_html" }, "devDependencies": { "babel-brunch": "6.0.6", "brunch": "2.10.7", "clean-css-brunch": "2.10.0", "sass-brunch": "^2.10.4", "uglify-js-brunch": "2.1.1" } }

[更新]

我发现了一个有趣的事实。

我找到了解决问题的方法。

将这些行放入 brunch-config.js:

watcher: { usePolling: true }

正如 Brunch 的 documentation 所说,通过将 true 设置为此选项,watcher 变得更慢但可以更可靠。

usePolling 选项被传递给 chokidar,其文档说:

usePolling (default: false). Whether to use fs.watchFile (backed by polling), or fs.watch. If polling leads to high CPU utilization, consider setting this to false. It is typically necessary to set this to true to successfully watch files over a network, and it may be necessary to successfully watch files in other non-standard situations.