ant-design-vue/antd-tools/getBabelCommonConfig.js

54 lines
1.7 KiB
JavaScript
Raw Normal View History

2019-01-12 03:33:27 +00:00
'use strict';
2018-03-18 11:59:38 +00:00
2019-01-12 03:33:27 +00:00
module.exports = function(modules) {
2018-03-18 11:59:38 +00:00
const plugins = [
2020-10-07 14:49:01 +00:00
[require.resolve('@vue/babel-plugin-jsx'), { mergeProps: false }],
2020-08-14 14:58:13 +00:00
require.resolve('@babel/plugin-proposal-optional-chaining'),
2020-05-27 11:11:46 +00:00
require.resolve('@babel/plugin-transform-object-assign'),
require.resolve('@babel/plugin-proposal-object-rest-spread'),
2020-08-14 14:58:13 +00:00
require.resolve('@babel/plugin-proposal-export-default-from'),
2020-05-27 11:11:46 +00:00
require.resolve('@babel/plugin-proposal-class-properties'),
2020-08-14 14:58:13 +00:00
require.resolve('@babel/plugin-syntax-dynamic-import'),
// require.resolve('babel-plugin-inline-import-data-uri'),
// require.resolve('@babel/plugin-transform-member-expression-literals'),
// require.resolve('@babel/plugin-transform-property-literals'),
// require.resolve('@babel/plugin-proposal-export-default-from'),
// require.resolve('@babel/plugin-transform-object-assign'),
// require.resolve('@babel/plugin-transform-template-literals'),
// require.resolve('@babel/plugin-proposal-object-rest-spread'),
// require.resolve('@babel/plugin-proposal-class-properties'),
2019-01-12 03:33:27 +00:00
];
plugins.push([
2020-05-27 11:11:46 +00:00
require.resolve('@babel/plugin-transform-runtime'),
2019-01-12 03:33:27 +00:00
{
2020-05-27 11:11:46 +00:00
helpers: false,
2019-01-12 03:33:27 +00:00
},
]);
2018-03-18 11:59:38 +00:00
return {
2018-03-19 09:51:47 +00:00
presets: [
2019-01-12 03:33:27 +00:00
[
2020-05-27 11:11:46 +00:00
require.resolve('@babel/preset-env'),
2019-01-12 03:33:27 +00:00
{
modules,
targets: {
browsers: [
'last 2 versions',
'Firefox ESR',
'> 1%',
2020-08-14 14:58:13 +00:00
'ie >= 11',
2019-01-12 03:33:27 +00:00
'iOS >= 8',
'Android >= 4',
],
},
2018-03-19 09:51:47 +00:00
},
2019-01-12 03:33:27 +00:00
],
2018-03-19 09:51:47 +00:00
],
2018-03-18 11:59:38 +00:00
plugins,
2018-04-24 10:46:06 +00:00
env: {
test: {
plugins: [require.resolve('babel-plugin-istanbul')],
},
},
2019-01-12 03:33:27 +00:00
};
};