我使用的是 create-react-app ,并且只要标记的模板文字中有JavaScript并且注释掉了它(如下面的示例),它仍然会运行(它将应用重置, 在这种情况下)。
为什么会发生这种情况以及如何预防呢?
import { createGlobalStyle } from "styled-components";
import reset from "styled-reset";
export default createGlobalStyle`
/* the following line will run even though it's commented out */
/* ${reset} */
`
似乎create-react-app中的Webpack / Babel配置有问题吗?因为我无法在此沙箱上复制它:
https://codesandbox.io/s/p7qx411xvq
使用: styled-components@4.2.0