forked from redwoodjs/redwood
-
Notifications
You must be signed in to change notification settings - Fork 0
/
babel.config.js
93 lines (92 loc) · 2.74 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
const TARGETS_NODE = '12.13.0'
const TARGETS_BROWSERS = 'defaults'
// Warning! Recommended to specify used minor core-js version, like corejs: '3.6',
// instead of corejs: 3, since with corejs: 3 will not be injected modules which
// were added in minor core-js releases.
// https://github.com/zloirock/core-js/blob/master/README.md#babelpreset-env
const CORE_JS_VERSION = '3.6'
// We use the recommended babel configuration for monorepos, which is a base directory
// `babel.config.js` file, but then use a per-project `.babelrc.js` file.
// Learn more: https://babeljs.io/docs/en/config-files#monorepos
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: { node: TARGETS_NODE },
useBuiltIns: 'usage',
corejs: {
version: CORE_JS_VERSION,
// List of supported proposals: https://github.com/zloirock/core-js/blob/master/docs/2019-03-19-core-js-3-babel-and-a-look-into-the-future.md#ecmascript-proposals
proposals: true,
},
},
],
'@babel/preset-react',
'@babel/typescript',
],
plugins: [
[
'babel-plugin-module-resolver',
{
alias: {
src: './src',
},
},
],
['@babel/plugin-proposal-class-properties', { loose: true }],
[
'@babel/plugin-transform-runtime',
{
// https://babeljs.io/docs/en/babel-plugin-transform-runtime/#core-js-aliasing
// Setting the version here also requires `@babel/runtime-corejs3`
corejs: { version: 3, proposals: true },
// https://babeljs.io/docs/en/babel-plugin-transform-runtime/#version
// Transform-runtime assumes that @babel/[email protected] is installed.
// Specifying the version can result in a smaller bundle size.
// TODO: Grab version for package.json
version: '^7.8.3',
},
],
],
overrides: [
// ** WEB PACKAGES **
{
test: ['./packages/router', './packages/web/'],
presets: [
[
'@babel/preset-env',
{
targets: {
browsers: TARGETS_BROWSERS,
},
},
],
],
plugins: [
[
'babel-plugin-auto-import',
{
declarations: [
{
// import { React } from 'react'
default: 'React',
path: 'react',
},
{
// import { PropTypes } from 'prop-types'
default: 'PropTypes',
path: 'prop-types',
},
],
},
],
],
},
],
// Do not build tests or mocks in production.
ignore:
process.env.NODE_ENV === 'production'
? [/\.test\.(js|ts)/, '**/__tests__', '**/__mocks__']
: [],
}