【问题标题】:PostCSS-cssnext does not compile CSS-inputPostCSS-cssnext 不编译 CSS 输入
【发布时间】:2017-11-04 09:22:06
【问题描述】:

我对 postcss-cssnext 有一个问题:它没有按照我期望的方式编译我的 CSS。

这是我的 CSS 输入:

:root {
  --bgcolor: #fbc547;
}

body {
  background-color: var(--bgcolor);
}

不幸的是,输出看起来完全一样——但我期待这样的结果:

body {
  background-color: #fbc547;
}

为了更好地理解,这是我的 webpack.config.js 的样子:

module: {
  rules: [
    {
      test: /\.css$/,
      exclude: /node_modules/,
      use: [
        'style-loader',
        { loader: 'css-loader', options: { importLoaders: 1 } },
        'postcss-loader'
      ]
    }
  ]
}

这里是我的 postcss.config.js:

module.exports = {
  plugins: [
    require('postcss-smart-import'),
    require('postcss-cssnext')
  ]
}

Postcss-cssnext 版本是 2.11.0。我猜一般设置是有效的,因为供应商前缀已正确应用在 CSS 输出中。

我对 Webpack 和 Postcss 比较陌生。事实上,这是我第一次真正尝试使用它。所以我希望你们能帮助我:)

【问题讨论】:

    标签: webpack postcss cssnext


    【解决方案1】:

    使用require时,必须调用该函数。因此,您的配置应如下所示:

    module.exports = {
      plugins: [
        require('postcss-smart-import')(),
        require('postcss-cssnext')()
      ]
    }
    

    【讨论】:

      猜你喜欢
      • 2017-09-06
      • 1970-01-01
      • 2018-04-25
      • 2017-07-29
      • 2016-06-19
      • 2019-10-29
      • 2017-09-13
      • 2018-03-06
      • 2017-03-09
      相关资源
      最近更新 更多