mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-04-23 20:51:12 +08:00
Offer to set default browsers (#3792)
* Offer to set browser defaults * Catch error on no * Add ending newlines * Ensure we re-check to prevent defaults from leaking * Reduce nesting * Add defaults message * More explicit
This commit is contained in:
11
packages/react-scripts/scripts/init.js
vendored
11
packages/react-scripts/scripts/init.js
vendored
@@ -18,6 +18,8 @@ const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const chalk = require('chalk');
|
||||
const spawn = require('react-dev-utils/crossSpawn');
|
||||
const { defaultBrowsers } = require('react-dev-utils/browsersHelper');
|
||||
const os = require('os');
|
||||
|
||||
module.exports = function(
|
||||
appPath,
|
||||
@@ -43,16 +45,11 @@ module.exports = function(
|
||||
eject: 'react-scripts eject',
|
||||
};
|
||||
|
||||
appPackage.browserslist = {
|
||||
development: ['chrome', 'firefox', 'edge'].map(
|
||||
browser => `last 2 ${browser} versions`
|
||||
),
|
||||
production: ['>1%', 'last 4 versions', 'Firefox ESR', 'not ie < 11'],
|
||||
};
|
||||
appPackage.browserslist = defaultBrowsers;
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(appPath, 'package.json'),
|
||||
JSON.stringify(appPackage, null, 2)
|
||||
JSON.stringify(appPackage, null, 2) + os.EOL
|
||||
);
|
||||
|
||||
const readmeExists = fs.existsSync(path.join(appPath, 'README.md'));
|
||||
|
||||
Reference in New Issue
Block a user