-
-
Notifications
You must be signed in to change notification settings - Fork 106
/
index.ts
48 lines (45 loc) Β· 1.2 KB
/
index.ts
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
// @ts-nocheck
// see https://github.com/emotion-js/emotion/blob/master/packages/babel-preset-css-prop/src/index.js
import jsx from '@babel/plugin-transform-react-jsx'
import pragmatic from '@emotion/babel-plugin-jsx-pragmatic'
import emotion from '@emotion/babel-plugin'
const pragmaName = '___xstyledEmotionJSX'
// 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 (
api,
{
pragma,
sourceMap,
autoLabel,
labelFormat,
instances = [],
...options
} = {},
) => {
return {
plugins: [
[
pragmatic,
{
export: 'jsx',
module: '@xstyled/emotion',
import: pragmaName,
},
],
[jsx, { pragma: pragmaName, pragmaFrag: 'React.Fragment', ...options }],
[
emotion,
{
sourceMap,
autoLabel,
labelFormat,
instances: ['@xstyled/emotion', ...instances],
cssPropOptimization: true,
},
],
],
}
}