Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make browsers list configurable #2358

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8512933
Autoprefixer's browsers option is currently hardcoded. This PR adds t…
cr101 May 25, 2017
d2ba437
Merge branch 'master' of https://github.com/facebookincubator/create-…
cr101 May 25, 2017
377d70e
Merge branch 'master' of https://github.com/facebookincubator/create-…
cr101 May 25, 2017
a617388
Make the browsers list more readable
cr101 May 25, 2017
d479b9f
Stack the browsers underneath each other
cr101 May 25, 2017
aa25bab
Check if browserslist is in package.json and if not then force it
cr101 May 30, 2017
4c02989
Merge branch 'master' of https://github.com/facebookincubator/create-…
cr101 May 30, 2017
6d93bb7
Merge branch 'master' of https://github.com/facebookincubator/create-…
cr101 Jun 2, 2017
68fed74
Use default values when browserslist is not specified in package.json
cr101 Jun 2, 2017
ebc436a
Remove old 2009 syntax of Flexbox (i.e -webkit-box, -webkit-box-*) w…
cr101 Jun 2, 2017
9ec67b4
lerna-changelog
cr101 Jun 28, 2017
4f40f6f
upstream changes
cr101 Jun 28, 2017
7177a59
remove warning messages
cr101 Jun 29, 2017
fa50ef5
Merge branch 'master' into master
cr101 Jun 29, 2017
135b90d
Delete yarn.lock
cr101 Jun 29, 2017
30d3727
Delete cra.js
cr101 Jun 29, 2017
eb01f6d
update my local copy
cr101 Jun 29, 2017
1eeee99
Merge branch 'master' of https://github.com/facebookincubator/create-…
cr101 Jun 29, 2017
fedf184
Delete package-lock.json
cr101 Jun 29, 2017
6bc0271
Delete package-lock.json
cr101 Jun 29, 2017
621e2bd
Delete package-lock.json
cr101 Jun 29, 2017
89e8437
Delete package-lock.json
cr101 Jun 29, 2017
aed45d2
Delete package-lock.json
cr101 Jun 29, 2017
317cfe6
Merge branch 'master' of https://github.com/cr101/create-react-app
cr101 Jun 29, 2017
9bad6a7
Merge branch 'master' of https://github.com/facebookincubator/create-…
cr101 Jun 30, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions packages/react-scripts/config/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ const publicUrl = '';
// Get environment variables to inject into our app.
const env = getClientEnvironment(publicUrl);

// Get supported browsers list
let supportedBrowsers = require(paths.appPackageJson).browserslist;
if (!supportedBrowsers || Object.keys(supportedBrowsers).length === 0) {
// Assign default browsers when browserslist is not specified
supportedBrowsers =
"browsers: ['>1%', 'last 4 versions', 'Firefox ESR', 'not ie < 9', // React doesn't support IE8 anyway]";
}

// This is the development configuration.
// It is focused on developer experience and fast rebuilds.
// The production configuration is different and lives in a separate file.
Expand Down Expand Up @@ -225,12 +233,7 @@ module.exports = {
plugins: () => [
require('postcss-flexbugs-fixes'),
autoprefixer({
browsers: [
'>1%',
'last 4 versions',
'Firefox ESR',
'not ie < 9', // React doesn't support IE8 anyway
],
supportedBrowsers,
flexbox: 'no-2009',
}),
],
Expand Down
15 changes: 9 additions & 6 deletions packages/react-scripts/config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
const paths = require('./paths');
const getClientEnvironment = require('./env');

// Get supported browsers list
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be moved to a separate module to avoid DRY, maybe config/getSupportedBrowsers?

let supportedBrowsers = require(paths.appPackageJson).browserslist;
if (!supportedBrowsers || Object.keys(supportedBrowsers).length === 0) {
// Assign default browsers when browserslist is not specified
supportedBrowsers =
"browsers: ['>1%', 'last 4 versions', 'Firefox ESR', 'not ie < 9', // React doesn't support IE8 anyway]";
}

// Webpack uses `publicPath` to determine where the app is being served from.
// It requires a trailing slash, or the file assets will get an incorrect path.
const publicPath = paths.servedPath;
Expand Down Expand Up @@ -234,12 +242,7 @@ module.exports = {
plugins: () => [
require('postcss-flexbugs-fixes'),
autoprefixer({
browsers: [
'>1%',
'last 4 versions',
'Firefox ESR',
'not ie < 9', // React doesn't support IE8 anyway
],
supportedBrowsers,
flexbox: 'no-2009',
}),
],
Expand Down
6 changes: 6 additions & 0 deletions packages/react-scripts/scripts/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ module.exports = function(
eject: 'react-scripts eject',
};

// Add the supported browsers list
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)
Expand Down
12 changes: 4 additions & 8 deletions packages/react-scripts/template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -495,16 +495,12 @@ becomes this:

```css
.App {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
-ms-flex-direction: row;
flex-direction: row;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-ms-flex-direction: row;
flex-direction: row;
-ms-flex-align: center;
align-items: center;
}
```

Expand Down
Empty file modified tasks/local-test.sh
100755 → 100644
Empty file.