【问题标题】:object Object is not a PostCSS plugin | PostCSS Autoprefixer对象对象不是 PostCSS 插件 | PostCSS 自动前缀
【发布时间】:2021-06-11 17:58:54
【问题描述】:

我正在尝试使用 Grunt PostCSS Autoprefixer,但它一直说它不是 PostCSS 插件:

package.json

{
  "name": "test",
  "version": "0.2.0",
  "description": "test",
  "keywords": [
    ""
  ],
  "author": "",
  "license": "",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "dependencies": {
    "cssmin": "^0.4.3",
    "cssnano": "^5.0.6",
    "grunt": "^1.4.1",
    "grunt-babel": "^8.0.0",
    "grunt-contrib-cssmin": "^4.0.0",
    "grunt-contrib-uglify": "^5.0.1",
    "grunt-contrib-watch": "^1.1.0"
  },
  "devDependencies": {
    "@babel/core": "^7.14.5",
    "@babel/preset-env": "^7.14.5",
    "autoprefixer": "^10.2.6",
    "grunt-postcss": "^0.9.0",
    "grunt-postcss-import": "0.0.1",
    "grunt-prettify": "^0.4.0",
    "postcss": "^8.3.2"
  }
}

Gruntfile.js

postcss: {
  options: {
    map: {
      inline: false,
      annotation: 'dist/css/maps/'
    },
    processors: [
      // require('pixrem')(),
      require('autoprefixer')(),
      //require('cssnano')()
    ]
  },
  dist: {
    src: 'dist/css/bundle.css'
  }
},

我确保首先删除 grunt-autoprefixer 并安装 autoprefixer,它应该是一个 postcss 插件。

【问题讨论】:

    标签: gruntjs postcss autoprefixer


    【解决方案1】:

    原来这只是一个版本兼容性问题。我只是改变了:

    "autoprefixer": "^10.2.6",
    

    与:

    "autoprefixer": "^9.7.4",
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-28
      • 1970-01-01
      • 2017-02-26
      • 1970-01-01
      • 2018-05-30
      • 2021-05-20
      • 1970-01-01
      • 2017-09-07
      相关资源
      最近更新 更多