webpack autoprefixer加载browserslistrc

时间:2017-05-03 07:32:47

标签: webpack autoprefixer

我想用.browserslistrc文件加载我的浏览器配置webpack(css-loader与-webkit-flexbox前缀创建冲突。

所以,我创建了我的.browserslistrc文件并使用我的package.json进行测试,但我的配置未加载:

# Browsers that we support

Last 10 versions

我的package.json:

"devDependencies": {
    "autoprefixer": "^6.4.1",
    "babel-core": "^6.14.0",
    "babel-loader": "^6.2.5",
    "babel-preset-es2015": "^6.14.0",
    "babel-preset-stage-2": "^6.13.0",
    "browser-sync": "^2.14.3",
    "css-loader": "^0.24.0",
    "css-mqpacker": "^5.0.1",
    "eslint": "^3.18.0",
    "eslint-loader": "^1.6.3",
    "exports-loader": "^0.6.3",
    "extract-text-webpack-plugin": "^2.1.0",
    "node-sass": "^3.8.0",
    "postcss-loader": "^0.11.1",
    "progress-bar-webpack-plugin": "^1.9.0",
    "sass-loader": "^4.0.1",
    "script-loader": "^0.7.0",
    "style-loader": "^0.13.1",
    "webpack": "^2.0.0",
    "webpack-notifier": "^1.5.0"
},

任何人都已在webpack配置上添加.browserslistrc文件了吗?

1 个答案:

答案 0 :(得分:1)

我切换到"autoprefixer": "^7.1.1"中的package.json并在我的Webpack配置(1.x)中使用了内联require表单:

...

postcss() {
  return [
    require('autoprefixer'),
  ];
},

正确选择了.browserslistrc

之前,在版本6.x上,我必须在autoprefixer的webpack配置文件中手动指定它,文件未正确选取:

autoprefixer({
  browsers: [
    '>1%',
    'last 4 versions',
    'Firefox ESR',
    'not ie < 9', // React doesn't support IE8 anyway
  ]
}),

我认为browsers中的package.json选项也可行,但我从未测试过。