forked from twilio-labs/paste
-
Notifications
You must be signed in to change notification settings - Fork 0
/
babel.config.js
50 lines (48 loc) · 1.57 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
const getPresets = (isDev) => [
'@babel/preset-env',
'@babel/preset-react',
'@babel/preset-typescript',
[
/** [@emotion/babel-preset-css-prop]
* This preset is used to automatically enable Emotion’s css prop when using the classic JSX runtime.
* This plugin is configurable with all options from the following plugins:
* - `babel-plugin-transform-react-jsx`: https://babeljs.io/docs/en/babel-plugin-transform-react-jsx#options
* - `@emotion/babel-plugin`: https://github.com/emotion-js/emotion/tree/main/packages/babel-plugin
*
* React 17 introduced new JSX Transformations, which you can read about here: https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html
* @NOTE If/when we adopt these new transformations, we should:
* 1. remove this preset
* 2. add the `@emotion/babel` plugin to our plugin section.
*/
'@emotion/babel-preset-css-prop',
{
sourceMap: isDev,
autoLabel: 'dev-only',
labelFormat: '[local]',
cssPropOptimization: !isDev,
},
],
];
const BASE_PLUGINS = [
'macros',
['@babel/proposal-class-properties', {loose: true}],
'@babel/proposal-object-rest-spread',
['@babel/proposal-private-property-in-object', {loose: true}],
'@babel/plugin-proposal-optional-chaining',
];
module.exports = {
env: {
production: {
presets: getPresets(false),
plugins: BASE_PLUGINS,
},
development: {
presets: getPresets(true),
plugins: BASE_PLUGINS,
},
test: {
presets: getPresets(true),
plugins: BASE_PLUGINS,
},
},
};