-
Notifications
You must be signed in to change notification settings - Fork 1
/
babel-preset.js
59 lines (53 loc) · 1.05 KB
/
babel-preset.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
52
53
54
55
56
57
58
59
/* LOGGER CONFIG */
const loggerName = 'logger';
const levels = ['all', 'log', 'dir', 'debug', 'info', 'warn', 'error', 'none'];
/* LOGGER LOGIC */
levels.reverse();
const minLevel = level => {
const index = levels.findIndex(e => e === level);
if (index < 0) {
throw new Error(`Cannot find level ${level}`);
}
return levels
.slice(index + 1)
.filter(e => e !== 'all' && e !== 'none')
.map(e => `${loggerName}.${e}`);
};
/* BABEL CONFIG */
module.exports = () => ({
presets: ['next/babel'],
plugins: [
'babel-plugin-transform-class-properties',
'transform-flow-strip-types',
[
'module-resolver',
{
alias: {
src: './src',
},
},
],
],
env: {
production: {
plugins: [
[
'strip-function-call',
{
strip: minLevel('warn'),
},
],
],
},
staging: {
plugins: [
[
'strip-function-call',
{
strip: minLevel('info'),
},
],
],
},
},
});