【问题标题】:Using autoprefixer in node-sass在 node-sass 中使用自动前缀
【发布时间】:2020-03-08 22:27:45
【问题描述】:

当我尝试使用 autoprefixer 为我的 css 加上前缀时,我遇到了错误。下面是我的 package.json 文件。 Screenshot

{
  "name": "natours",
  "version": "1.0.0",
  "description": "Landing page for natours",
  "main": "index.js",
  "scripts": {
    "watch:sass": "node-sass sass/main.scss css/style.css -w",
    "compile:sass": "node-sass sass/main.scss css/style.comp.css",
    "concat:css": "concat -o css/style.concat.css css/icon-font.css css/style.comp.css",
    "prefix:css": "postcss --use autoprefixer -b 'last 5 versions' css/style.concat.css -o css/style.prefix.css"
  },
  "author": "Kenny",
  "license": "ISC",
  "devDependencies": {
    "autoprefixer": "^9.7.1",
    "concat": "^1.0.3",
    "node-sass": "^4.12.0",
    "postcss-cli": "^6.1.3"
  }
}

【问题讨论】:

  • 您还需要 postcss 在您只包含 postcss-cli 的开发依赖项中
  • 我明白了,所以我所做的是我也安装了 postcss。 npm install postcss --save-dev 以便将其添加为开发依赖项并且确实如此。但我仍然无法成功为我的 css imgur.com/IVpODBn 添加前缀

标签: sass node-sass autoprefixer


【解决方案1】:

我认为你需要调整命令行参数的顺序。

通过查看documentation,其中一个示例如下所示:

postcss <input.css>... [OPTIONS] --dir <output-directory>

因此,如果您将输入文件移到开头,它可能会成功:

postcss css/style.concat.css --use autoprefixer -b 'last 5 versions' -o css/style.prefix.css

【讨论】:

  • 即使我按照代码的方向也无法正常工作。
猜你喜欢
  • 2018-04-06
  • 2021-08-11
  • 1970-01-01
  • 2022-08-17
  • 2017-03-15
  • 2016-03-15
  • 2014-07-05
  • 1970-01-01
  • 2017-03-24
相关资源
最近更新 更多