(发送值而不是Error实例)bulma css中的postcss-custom-properties

时间:2017-11-12 19:28:17

标签: ruby-on-rails webpack bulma

摘要

我在使用webpacker的rails5应用程序上使用Bulma CSS Framework。 当我将css文件构建为./bin/webpack-dev-server时,我收到如下警告。有谁知道消除它们?

23:37:47 webpacker.1 | WARNING in ./node_modules/css-loader?{"minimize":false}!./node_modules/postcss-loader/lib?{"sourceMap":true}!./node_modules/resolve-url-loader!./node_modules/sass-loader/lib/loader.js?{"sourceMap":true}!./node_modules/import-glob-loader!./app/javascript/stylesheets/application.scss 23:37:47 webpacker.1 | (Emitted value instead of an instance of Error) postcss-custom-properties: /some_rails_app/app/javascript/stylesheets/application.scss:9284:3: Custom property ignored: not scoped to the top-level :root element (.columns.is-variable { ... --columnGap: ... })

版本

  • Rails:5.1.4
  • 布尔玛:0.6.1
  • Ruby:2.4.1p111
  • Webpacker:3.0.2

2 个答案:

答案 0 :(得分:1)

我在github上发现了这个问题https://github.com/MoOx/postcss-cssnext/issues/186,以及我如何设置摆脱警告。

<强>终端

yarn add postcss-cssnext

config / webpack / loaders / sass.js

中为postcss-loader添加新选项
{
  loader: 'postcss-loader',
  options: {
    sourceMap: true,
    plugins: (loader) => [
      require('postcss-cssnext')({
        features: {
          customProperties: {
            warnings: false
          }
        }
      })
    ]
  }
},

或者,如果你没有使用postcss,只需删除postcss-loader,你就可以了。

答案 1 :(得分:1)

我在React和webpack配置方面遇到了类似的问题。所以我添加了postcss.config.js文件并添加了以下代码:

const postcssCssNext = require('postcss-cssnext')
const postcssImport = require('postcss-import')

module.exports = {
    plugins: [
        postcssCssNext({
            features: {
                customProperties: {
                    warnings: false
                }
            }
        }),
        postcssImport
    ]
}