-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbabel.config.cjs
29 lines (27 loc) · 887 Bytes
/
babel.config.cjs
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
module.exports = function configureBabel(api) {
api.cache(true); // This tells babel to cache it's transformations, it's pretty good at checking file hashes and invalidating it's cache, but if you have problems with changes not being reflected you can set false here.
const presets = [
[
'@babel/preset-env', // This plugin tells babel to transpile your code for a specific runtime environment, we'll use node
{
targets: {
node: '16.0.0',
},
modules: 'cjs',
},
],
[
'@babel/preset-typescript', // This plugin allows babel to work with typescript (bear in mind it will only transpile it, it doesn't care if you have type errors)
],
];
const plugins = [
[
'babel-plugin-replace-import-extension',
{ extMapping: { '.js': '.cjs' } },
],
];
return {
presets,
plugins,
};
};