forked from ElemeFE/element
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbabel.config.js
51 lines (46 loc) · 1.21 KB
/
babel.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const browserslist = require('browserslist');
module.exports = function(api) {
const isTest = api.env('test');
// Polyfilling
const polyfillExclusions = [
'es.number.constructor',
'es.regexp.*',
'es.array.sort'
];
let targets;
// Target node and transform dynamic imports when testing
if (isTest) {
targets = { node: 'current' };
} else { targets = browserslist(null, { env: api.env() }); }
const plugins = [];
if (api.env('utils')) {
plugins.push([
require.resolve('babel-plugin-module-resolver'), {
root: ['@cognitoforms/element-ui'],
alias: {
'@cognitoforms/element-ui/src': '@cognitoforms/element-ui/lib'
}
}
]);
}
return {
plugins,
presets: [
'@vue/babel-preset-jsx',
[
'@babel/preset-env',
{
// debug: true,
loose: true,
modules: api.env('utils') ? 'commonjs' : false,
corejs: 3,
targets,
// Allows use of module.exports instead of just export keyword?
// Polyfills are automatically imported in files where features are used
useBuiltIns: 'usage',
exclude: polyfillExclusions
}
]
]
};
};