-
Notifications
You must be signed in to change notification settings - Fork 375
Expand file tree
/
Copy pathbabel.config.js
More file actions
27 lines (24 loc) · 930 Bytes
/
babel.config.js
File metadata and controls
27 lines (24 loc) · 930 Bytes
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
// Babel config is only used by Jest (babel-jest) and ESLint (@babel/eslint-parser)
// Production webpack builds use SWC instead (see config/swc.config.js)
module.exports = function (api) {
const defaultConfigFunc = require('shakapacker/package/babel/preset.js');
const resultConfig = defaultConfigFunc(api);
const isProductionEnv = api.env('production');
// Add React preset for Jest testing and ESLint
// Note: @babel/preset-react is in devDependencies (only needed for Jest/ESLint, not webpack)
const changesOnDefault = {
presets: [
[
'@babel/preset-react',
{
runtime: 'automatic',
// Use development mode for better error messages in tests and development
development: !isProductionEnv,
useBuiltIns: true,
},
],
],
};
resultConfig.presets = [...resultConfig.presets, ...changesOnDefault.presets];
return resultConfig;
};