带标签的模板文字(字符串)中的带注释的JS仍将运行

时间:2019-04-26 14:12:19

标签: javascript css ecmascript-6 create-react-app styled-components

我使用的是 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

0 个答案:

没有答案