Skip to content

Commit

Permalink
feat(babel): improve config
Browse files Browse the repository at this point in the history
  • Loading branch information
mverissimo committed Jan 21, 2021
1 parent 8cfe275 commit dd3780a
Show file tree
Hide file tree
Showing 8 changed files with 531 additions and 420 deletions.
54 changes: 54 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const isProd = process.env.NODE_ENV === 'production';

module.exports = (api) => {
api.cache(true);

const presets = [
'@babel/preset-typescript',
[
'@babel/preset-env',
{
loose: true,
targets: {
esmodules: !isProd,
},
},
],
isProd && [
'@babel/preset-react',
{
runtime: 'automatic',
},
],
!isProd && [
'@babel/preset-react',
{
development: true,
runtime: 'automatic',
importSource: '@emotion/react',
},
],
!isProd && [
'@emotion/babel-preset-css-prop',
{
labelFormat: '[filename]--[local]',
},
],
].filter(Boolean);

const plugins = [
'lodash',
isProd && [
'@emotion',
{
sourceMap: false,
autoLabel: 'never',
},
],
].filter(Boolean);

return {
presets,
plugins,
};
};
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"lint:fix": "yarn lint --fix",
"test": "jest --watch",
"test:ci": "jest --ci --coverage --runInBand --json --outputFile=reports/jest/results.json",
"build": "preconstruct build",
"build": "NODE_ENV=production preconstruct build",
"prepublishOnly": "yarn build",
"release": "semantic-release"
},
Expand Down Expand Up @@ -67,6 +67,7 @@
"@babel/preset-typescript": "7.12.7",
"@commitlint/cli": "11.0.0",
"@commitlint/config-conventional": "11.0.0",
"@emotion/babel-plugin": "^11.1.2",
"@emotion/babel-preset-css-prop": "^11.0.0",
"@emotion/eslint-plugin": "^11.0.0",
"@emotion/jest": "^11.1.0",
Expand All @@ -82,6 +83,7 @@
"@typescript-eslint/parser": "4.14.0",
"babel-eslint": "10.1.0",
"babel-jest": "26.6.3",
"babel-plugin-lodash": "^3.3.4",
"cz-conventional-changelog": "3.3.0",
"docz": "2.3.1",
"eslint": "7.18.0",
Expand Down
Loading

0 comments on commit dd3780a

Please sign in to comment.