From 8512933bd66fd08b84b7a2ac697a2f0dcd9fff42 Mon Sep 17 00:00:00 2001 From: Cristian Date: Thu, 25 May 2017 15:58:10 +1200 Subject: [PATCH] Autoprefixer's browsers option is currently hardcoded. This PR adds the browserslist key in package.json which allows developers to set browsers list in queries like "Chrome >= 35", "Firefox >= 38" for both production and development. Autoprefixer which relies on Browserslist will find its config automatically. This PR fixes #2248 and #892 --- packages/react-scripts/config/webpack.config.dev.js | 6 ------ packages/react-scripts/config/webpack.config.prod.js | 6 ------ packages/react-scripts/package.json | 2 +- packages/react-scripts/scripts/init.js | 5 +++++ 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index adf92f5b124..909d4f91f16 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -221,12 +221,6 @@ module.exports = { plugins: () => [ require('postcss-flexbugs-fixes'), autoprefixer({ - browsers: [ - '>1%', - 'last 4 versions', - 'Firefox ESR', - 'not ie < 9', // React doesn't support IE8 anyway - ], flexbox: 'no-2009', }), ], diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 3de2775e030..1a207c01cee 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -227,12 +227,6 @@ module.exports = { plugins: () => [ require('postcss-flexbugs-fixes'), autoprefixer({ - browsers: [ - '>1%', - 'last 4 versions', - 'Firefox ESR', - 'not ie < 9', // React doesn't support IE8 anyway - ], flexbox: 'no-2009', }), ], diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 06b0d6b76c4..bf7060c703b 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -21,7 +21,7 @@ "react-scripts": "./bin/react-scripts.js" }, "dependencies": { - "autoprefixer": "7.1.0", + "autoprefixer": "7.1.1", "babel-core": "6.24.1", "babel-eslint": "7.2.3", "babel-jest": "20.0.3", diff --git a/packages/react-scripts/scripts/init.js b/packages/react-scripts/scripts/init.js index a50704d1cf7..ab68d6024c7 100644 --- a/packages/react-scripts/scripts/init.js +++ b/packages/react-scripts/scripts/init.js @@ -49,6 +49,11 @@ module.exports = function( eject: 'react-scripts eject', }; + appPackage.browserslist = { + production: ['> 1%', 'last 4 versions', 'Firefox ESR', 'not ie < 9'], + development: ['last 1 version'], + }; + fs.writeFileSync( path.join(appPath, 'package.json'), JSON.stringify(appPackage, null, 2)