简体   繁体   English

Webpack:抑制来自特定文件的警告

[英]Webpack: Suppressing warnings from a specific file

I'm trying to suppress some FontAwesome Sass compilation warnings that obviously cannot be fixed from my end like so:我正在尝试抑制一些 FontAwesome Sass 编译警告,这些警告显然无法从我的最终修复,如下所示:

config.ignoreWarnings = [
  {
    file: /_bootstrap\.scss$/i
  }
]

But the warnings are not ignored or suppressed.但警告不会被忽略或抑制。 Maybe ignoreWarnings does not suppress compilation warnings?也许ignoreWarnings不会抑制编译警告? Regardless, how can warnings generated from compiling this Sass file be ignored?无论如何,如何忽略编译这个 Sass 文件产生的警告?

Generated Warnings生成的警告

DEPRECATION WARNING: Using / for division is deprecated and will be removed in Dart Sass 2.0.0.

Recommendation: math.div(20em, 16)

More info and automated migrator: https://sass-lang.com/d/slash-div

   ╷
12 │ $fa-fw-width:          (20em / 16);
   │                         ^^^^^^^^^
   ╵
    node_modules\@fortawesome\fontawesome-free\scss\_variables.scss 12:25  @import
    node_modules\@fortawesome\fontawesome-free\scss\fontawesome.scss 5:9   @import
    assets\styles\_bootstrap.scss 4:9                                      @import
    assets\styles\app.scss 1:9                                             root stylesheet

DEPRECATION WARNING: Using / for division is deprecated and will be removed in Dart Sass 2.0.0.

Recommendation: math.div(4em, 3)

More info and automated migrator: https://sass-lang.com/d/slash-div

  ╷
6 │   font-size: (4em / 3);
  │               ^^^^^^^
  ╵
    node_modules\@fortawesome\fontawesome-free\scss\_larger.scss 6:15     @import
    node_modules\@fortawesome\fontawesome-free\scss\fontawesome.scss 8:9  @import
    assets\styles\_bootstrap.scss 4:9                                     @import
    assets\styles\app.scss 1:9                                            root stylesheet

DEPRECATION WARNING: Using / for division is deprecated and will be removed in Dart Sass 2.0.0.

Recommendation: math.div(3em, 4)

More info and automated migrator: https://sass-lang.com/d/slash-div

  ╷
7 │   line-height: (3em / 4);
  │                 ^^^^^^^
  ╵
    node_modules\@fortawesome\fontawesome-free\scss\_larger.scss 7:17     @import
    node_modules\@fortawesome\fontawesome-free\scss\fontawesome.scss 8:9  @import
    assets\styles\_bootstrap.scss 4:9                                     @import
    assets\styles\app.scss 1:9                                            root stylesheet

DEPRECATION WARNING: Using / for division is deprecated and will be removed in Dart Sass 2.0.0.

Recommendation: math.div($fa-li-width * 5, 4)

More info and automated migrator: https://sass-lang.com/d/slash-div

  ╷
6 │   margin-left: $fa-li-width * 5/4;
  │                ^^^^^^^^^^^^^^^^^^
  ╵
    node_modules\@fortawesome\fontawesome-free\scss\_list.scss 6:16        @import
    node_modules\@fortawesome\fontawesome-free\scss\fontawesome.scss 10:9  @import
    assets\styles\_bootstrap.scss 4:9                                      @import
    assets\styles\app.scss 1:9                                             root stylesheet

 DONE  Compiled successfully in 7725ms

Try the below,试试下面,

ignoreWarnings: [
      {
        file: /file_name/,
        message: /your warning message that need to be suppressed/,
      },
      (warning, compilation) => true
    ]

Ref: https://webpack.js.org/configuration/参考: https ://webpack.js.org/configuration/

In my case using file regex didn't work, I fixed it using module regex instead在我的情况下,使用file regex不起作用,我改用module regex修复它

Not working不工作

ignoreWarnings: [
    {
        file: /path\/to\/file\/style.scss$/,
        message: /the warning/,
    },
],

Working在职的

ignoreWarnings: [
    {
        module: /path\/to\/file\/style.scss$/,
        message: /the warning/,
    },
],

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM