Target Babel to latest Chrome Versions in dev (#3806)
* Use `babel-preset-env` to target Babel to latest Chrome Versions * Opt-In mechanism for Babel Preset Env
This commit is contained in:
parent
95af942fc9
commit
d3077c51fc
@ -59,6 +59,7 @@
|
|||||||
"babel-plugin-transform-runtime": "6.15.0",
|
"babel-plugin-transform-runtime": "6.15.0",
|
||||||
"babel-plugin-webpack-alias": "2.1.2",
|
"babel-plugin-webpack-alias": "2.1.2",
|
||||||
"babel-polyfill": "6.20.0",
|
"babel-polyfill": "6.20.0",
|
||||||
|
"babel-preset-env": "1.0.2",
|
||||||
"babel-preset-es2015": "6.18.0",
|
"babel-preset-es2015": "6.18.0",
|
||||||
"babel-preset-es2016": "6.16.0",
|
"babel-preset-es2016": "6.16.0",
|
||||||
"babel-preset-es2017": "6.16.0",
|
"babel-preset-es2017": "6.16.0",
|
||||||
|
@ -36,6 +36,29 @@ function getBabelrc () {
|
|||||||
// [ "es2015", { "modules": false } ]
|
// [ "es2015", { "modules": false } ]
|
||||||
babelrc.presets[es2015Index] = [ 'es2015', { modules: false } ];
|
babelrc.presets[es2015Index] = [ 'es2015', { modules: false } ];
|
||||||
babelrc['babelrc'] = false;
|
babelrc['babelrc'] = false;
|
||||||
|
|
||||||
|
const BABEL_PRESET_ENV = process.env.BABEL_PRESET_ENV;
|
||||||
|
const npmStart = process.env.npm_lifecycle_event === 'start';
|
||||||
|
const npmStartApp = process.env.npm_lifecycle_event === 'start:app';
|
||||||
|
|
||||||
|
if (BABEL_PRESET_ENV && (npmStart || npmStartApp)) {
|
||||||
|
console.log('using babel-preset-env');
|
||||||
|
|
||||||
|
babelrc.presets = [
|
||||||
|
// 'es2017',
|
||||||
|
'stage-0', 'react',
|
||||||
|
[
|
||||||
|
'env',
|
||||||
|
{
|
||||||
|
targets: { browsers: ['last 2 Chrome versions'] },
|
||||||
|
modules: false,
|
||||||
|
loose: true,
|
||||||
|
useBuiltIns: true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
return babelrc;
|
return babelrc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user