-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
babel.config.js
38 lines (36 loc) · 1.05 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
// inspired by https://github.com/mui-org/material-ui/blob/next/babel.config.js
let defaultPresets
const environemnt = process.env.BABEL_ENV || 'umd'
// We release a ES version of the package.
// It's something that matches the latest official supported features of JavaScript.
// Nothing more (stage-1, etc), nothing less (require, etc).
if (environemnt === 'es') {
defaultPresets = []
} else {
defaultPresets = [
[
'@babel/preset-env',
{
modules: ['esm', 'umd'].includes(environemnt) ? false : 'commonjs',
},
],
]
}
module.exports = {
presets: [...defaultPresets, '@babel/preset-react'],
plugins: [
/** mainly required to make storybook work, see
* - https://github.com/storybooks/storybook/issues/3346#issuecomment-415982589
* - https://github.com/storybooks/storybook/issues/3346#issuecomment-423719241
*/
'@babel/plugin-transform-modules-commonjs',
[
'babel-plugin-styled-components',
{
ssr: true,
displayName: true,
fileName: false,
},
],
],
}