【问题标题】:gulp-less fails when using !important使用 !important 时 gulp-less 失败
【发布时间】:2019-08-20 07:53:10
【问题描述】:

当我们对特定的 less 变量使用 !important 时,构建会失败。我们在所有地方都使用 !important,我不知道是什么让这个有什么不同。

设置:

customer1.less

@import "basefile";

@wrapper-height: auto !important;
...

basefile.less

@import 'variables/basefile-variables';
...

basefile-variables.less

@wrapper-height: auto;
...

运行 gulp-less 时出错:

Error in plugin "gulp-less"
Message:
    Cannot create property '_index' on string '!important' in file /<redacted>/customer1.less line no. 1
Details:
    type: Syntax
    filename: /<redacted>/customer1.less
    index: NaN
    line: 1
    column: -1
    callLine: NaN
    callExtract: undefined
    extract: ,@import "basefile";,
    lineNumber: 1
    fileName: /<redacted>/customer1.less

【问题讨论】:

  • 我今天遇到了类似的问题,在特定机器上编译失败并显示相同的消息。在这种情况下,从有问题的文件中找到的两个地方删除“!important”属性解决了这个问题。 gulp-less 4.0.1.
  • @swalladge 是的,这就是我们最终要做的,但在 gulp-less 中肯定存在某种错误。

标签: javascript css gulp less


【解决方案1】:

可能是您的变量 @wrapper-height 带有连字符。

尝试使用类似 @wrapperHeight 的 var 名称,看看 Gulp 是如何处理的。

更新: 实际上,您正在尝试导入 basefile 而不是 basefile.less - 尝试添加 .less 文件扩展名。

【讨论】:

  • 不,我们到处都有连字符的变量,以前这不是问题。您不需要将 .less 添加到导入中,没有它们也可以正常工作。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-04
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多