-
Notifications
You must be signed in to change notification settings - Fork 287
/
Copy pathbabelLoader.js
46 lines (45 loc) · 984 Bytes
/
babelLoader.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
// [babel-loader 配置]
/**
* @name babel-loader
* @description babel-loader 配置
*/
module.exports = ({ config }) => {
const presets = [
['@babel/typescript'],
[
'@babel/preset-env',
{
modules: false,
targets: {
chrome: 59,
edge: 13,
firefox: 50,
safari: 8
}
}
]
]
const babelConf = {
env: {
test: {
plugins: ['@babel/plugin-transform-modules-commonjs']
}
},
presets,
plugins: [
'transform-class-properties',
'@babel/proposal-object-rest-spread',
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-proposal-class-properties',
['import', { libraryName: 'antd', style: true }]
]
}
const baseRule = config.module.rule('babel').test(/.[jt]sx?$/)
return () => {
baseRule
.use('babel')
.loader(require.resolve('babel-loader'))
.options(babelConf)
.after('process-env')
}
}