-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
index.js
42 lines (40 loc) · 1013 Bytes
/
index.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
import jsx from '@babel/plugin-transform-react-jsx'
import pragmatic from 'babel-plugin-jsx-pragmatic'
import emotion from 'babel-plugin-emotion'
let pragmaName = '___EmotionJSX'
// pull out the emotion options and pass everything else to the jsx transformer
// this means if @babel/plugin-transform-react-jsx adds more options, it'll just work
// and if babel-plugin-emotion adds more options we can add them since this lives in
// the same repo as babel-plugin-emotion
export default ({
pragma,
sourceMap,
autoLabel,
labelFormat,
instances,
...options
}) => {
return {
plugins: [
[
pragmatic,
{
export: 'jsx',
module: '@emotion/core',
import: pragmaName
}
],
[jsx, { pragma: pragmaName, pragmaFrag: 'React.Fragment', ...options }],
[
emotion,
{
sourceMap,
autoLabel,
labelFormat,
instances,
cssPropOptimization: true
}
]
]
}
}