Skip to content
This repository was archived by the owner on Jun 12, 2025. It is now read-only.

Commit b00c986

Browse files
authored
Merge pull request #171 from mverissimo/feat/babel-emotion
feat(babel): improve config
2 parents 8cfe275 + dd3780a commit b00c986

File tree

8 files changed

+531
-420
lines changed

8 files changed

+531
-420
lines changed

babel.config.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
const isProd = process.env.NODE_ENV === 'production';
2+
3+
module.exports = (api) => {
4+
api.cache(true);
5+
6+
const presets = [
7+
'@babel/preset-typescript',
8+
[
9+
'@babel/preset-env',
10+
{
11+
loose: true,
12+
targets: {
13+
esmodules: !isProd,
14+
},
15+
},
16+
],
17+
isProd && [
18+
'@babel/preset-react',
19+
{
20+
runtime: 'automatic',
21+
},
22+
],
23+
!isProd && [
24+
'@babel/preset-react',
25+
{
26+
development: true,
27+
runtime: 'automatic',
28+
importSource: '@emotion/react',
29+
},
30+
],
31+
!isProd && [
32+
'@emotion/babel-preset-css-prop',
33+
{
34+
labelFormat: '[filename]--[local]',
35+
},
36+
],
37+
].filter(Boolean);
38+
39+
const plugins = [
40+
'lodash',
41+
isProd && [
42+
'@emotion',
43+
{
44+
sourceMap: false,
45+
autoLabel: 'never',
46+
},
47+
],
48+
].filter(Boolean);
49+
50+
return {
51+
presets,
52+
plugins,
53+
};
54+
};

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"lint:fix": "yarn lint --fix",
2424
"test": "jest --watch",
2525
"test:ci": "jest --ci --coverage --runInBand --json --outputFile=reports/jest/results.json",
26-
"build": "preconstruct build",
26+
"build": "NODE_ENV=production preconstruct build",
2727
"prepublishOnly": "yarn build",
2828
"release": "semantic-release"
2929
},
@@ -67,6 +67,7 @@
6767
"@babel/preset-typescript": "7.12.7",
6868
"@commitlint/cli": "11.0.0",
6969
"@commitlint/config-conventional": "11.0.0",
70+
"@emotion/babel-plugin": "^11.1.2",
7071
"@emotion/babel-preset-css-prop": "^11.0.0",
7172
"@emotion/eslint-plugin": "^11.0.0",
7273
"@emotion/jest": "^11.1.0",
@@ -82,6 +83,7 @@
8283
"@typescript-eslint/parser": "4.14.0",
8384
"babel-eslint": "10.1.0",
8485
"babel-jest": "26.6.3",
86+
"babel-plugin-lodash": "^3.3.4",
8587
"cz-conventional-changelog": "3.3.0",
8688
"docz": "2.3.1",
8789
"eslint": "7.18.0",

0 commit comments

Comments
 (0)