css - 当 sass 同时使用 calc 和 var 时,React 构建失败

标签 css reactjs build sass create-react-app

我正在使用 create-react-app 构建我的应用程序,当我在开发模式下运行它时,它没有任何错误或警告。当我在 sass 中一起使用 calc 和 var 时,当我在终端上运行 npm run build 时出现构建错误。

transform: translate(calc((var(--i) -1)*-100%));

当我取消对上述代码的注释时,构建不会失败,所以我假设这就是问题所在。

这很奇怪,因为当我运行 npm start 时它工作得很好。

错误信息如下。

yarn run v1.16.0
$ react-scripts build
Creating an optimized production build...
Failed to compile.

./src/styles/core.scss
ParserError: Syntax Error at line: 1, column 31


error Command failed with exit code 1.

最佳答案

这在包含 calc() 来计算减法和运算符之间包含空格时有效。

transform: translate(calc(calc((var(--i) - 1)) * -100%));

关于css - 当 sass 同时使用 calc 和 var 时,React 构建失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56744733/

相关文章:

html - 如何在 react 中添加默认 Prop 或值(value)

javascript - 在 react 功能组件中使用 useEffect 时出错

reactjs - 警告 : Hash history cannot PUSH the same path; a new entry will not be added to the history stack

grails - Gradle - 创建具有不同版本依赖项的多个 jar

javascript - Electron Forge 为其他平台构建应用程序

c - 如何列出静态库中带有 .o 扩展名的文件名

html - Figcaption 宽度不适合图像 - 'width: fit-content' 无效

css - 仅在 WooCommerce 单个产品页面上增加产品价格字体大小

php - 如何在 Codeigniter 中加载图像?

html - CSS A 悬停排除当前元素