-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.babelrc.js
More file actions
57 lines (52 loc) · 1.54 KB
/
Copy path.babelrc.js
File metadata and controls
57 lines (52 loc) · 1.54 KB
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
module.exports = function config(api) {
api.cache.using(() => process.env.BABEL_ENV);
const presets = [
'@babel/preset-react',
[
'@babel/preset-typescript',
{
allExtensions: true,
isTSX: true,
},
],
];
const plugins = [
['react-remove-properties', {properties: ['data-testid']}],
[
require.resolve('babel-plugin-module-resolver'),
{
alias: {
styles: './src/styles',
components: './src/components',
},
},
],
];
const ignore = [
'**/*.stories.tsx',
'**/*.test.ts',
'**/*.test.tsx',
// The OKLCH generation engine and its colorjs.io dependency are
// build/script-only — runtime ships only the prebuilt theme-tokens.css and
// the tiny `var(--color-*)` references in paletteV2.generated.ts / tokens.ts
// (which import the engine for types only). Excluding these keeps colorjs.io
// out of the published bundle.
'**/color-system/colorEngineAdapter.ts',
'**/color-system/generatedTheme.ts',
'**/color-system/websiteGeneratedThemeConfig.ts',
// The Storybook generator sandbox pulls the engine (and colorjs.io) — it is
// a dev/Storybook-only tool and must not ship in the runtime bundle.
'**/color-system/generator/**',
];
if (api.env() === 'cjs') {
return {
ignore,
plugins: ['@babel/plugin-transform-runtime', ...plugins],
presets: ['@babel/preset-env', ...presets],
};
}
if (api.env() === 'esm') {
return {ignore, presets, plugins};
}
return {};
};