forked from marktext/marktext
-
Notifications
You must be signed in to change notification settings - Fork 0
/
babel.config.js
56 lines (52 loc) · 1.39 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
52
53
54
55
56
const proposalClassProperties = require('@babel/plugin-proposal-class-properties')
const syntaxClassProperties = require('@babel/plugin-syntax-class-properties')
const transformRuntime = require('@babel/plugin-transform-runtime')
const syntaxDynamicImport = require('@babel/plugin-syntax-dynamic-import')
const functionBind = require('@babel/plugin-proposal-function-bind')
const exportDefault = require('@babel/plugin-proposal-export-default-from')
const isTanbul = require('babel-plugin-istanbul')
const component = require('babel-plugin-component')
const presetEnv = require('@babel/preset-env')
const presetsHash = {
test: [
[presetEnv,
{
targets: { 'node': 16 }
}]
],
main: [
[presetEnv,
{
targets: { 'node': 16 }
}]
],
renderer: [
[presetEnv,
{
useBuiltIns: false,
targets: {
electron: require('electron/package.json').version,
node: 16
}
}]
]
}
module.exports = function (api) {
const plugins = [ proposalClassProperties, syntaxClassProperties, transformRuntime, syntaxDynamicImport, functionBind, exportDefault ]
const env = api.env()
const presets = presetsHash[env]
if (env === 'test') {
plugins.push(isTanbul)
} else if (env === 'renderer') {
plugins.push(
[component, {
style: false,
libraryName: 'element-ui'
}
])
}
return {
presets,
plugins
}
}