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