我正在尝试生成ES6模块而不是ES5。根据{{3}}的文章,我在目标中添加了浏览器,但仍然生成了ES5模块。我做错了什么,如何生成ES6模块?
const rewire = require('rewire');
const defaults = rewire('react-scripts/scripts/build.js');
let config = defaults.__get__('config');
config.optimization.splitChunks = {
name: true,
chunks: 'initial',
cacheGroups:
{
default: false
},
};
config.optimization.runtimeChunk = false;
config.module.rules[2].oneOf[1].options.plugins.push(['lodash']);
// LESS processors
const defaultRules = config.module.rules;
// Find object which has oneOf
// OR get the last object -> coz this is recommended to have fileLoader as the last option
const loaderOptions = defaultRules[defaultRules.length - 1];
loaderOptions.oneOf[2].options.presets[0][1] = {
...loaderOptions.oneOf[2].options.presets[0][1],
targets: {
browsers: [
'Chrome >= 60',
'Safari >= 10.1',
'iOS >= 10.3',
'Firefox >= 54',
'Edge >= 15',
]
}
}