我使用了 create-react-app 并安装了 node-sass 作为依赖。react版本是V16.13.1.,node-sass版本是V4.14.1。两者都应该是最新版本。
我的问题是,如果我在 scss 文件中使用 @debug $some-variable,它不会出现在我的终端中。然而,有趣的是当我杀死终端并再次重新启动它时,它会弹出几分之一秒然后再次消失。@warn 规则也是如此。
解决方法是改用@error,@error 规则总是拦截终端并且 100% 弹出错误,我用它作为一种解决方法来调试我的 scss 代码。
但我相信问题出在 node-sass 端,@debug/@warn 应该打印出一些东西,但只是在 react 脚本端被覆盖了,即被“react-scripts start”脚本覆盖。在我看来,应该有一种方法可以阻止 react 端执行此操作,并将 stdout 信息保留在终端上。也许在 node-sass 中添加一个标志或修改反应端的启动脚本?
我希望我能正确解决问题。有没有人有这个问题的经验?请指教。
示例代码:
在 foo.scss 文件中:
@debug "hello world" // it does not print anything in terminal
@warn "this is a warning" // it does not print anything in terminal either
@error "it definately catch this" // the error shows up in terminal only
Run Code Online (Sandbox Code Playgroud)