generated from ivandotv/microbundle-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.babelrc.cjs
47 lines (39 loc) · 1.09 KB
/
.babelrc.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* eslint-disable @typescript-eslint/no-var-requires */
const pkg = require('./package.json')
const { execSync } = require('child_process')
const pkgVersion = process.env.PKG_VERSION || pkg.version
const nodeEnv = process.env.NODE_ENV || 'production'
const buildDate = execSync('git show -s --format=%ci HEAD')
.toString()
.replace(/[\r\n]+$/, '')
const commitSha = execSync('git rev-parse --short HEAD')
.toString()
.replace(/[\r\n]+$/, '')
const replacements = {
__VERSION__: pkgVersion,
__BUILD_DATE__: buildDate,
__COMMIT_SHA__: commitSha,
'process.env.NODE_ENV': nodeEnv
}
const plugins = ['dev-expression', ['transform-define', replacements]]
//default babel config
const config = { plugins }
//babel config for Jest tests
const jestConfig = {
plugins,
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current'
}
}
],
'@babel/preset-typescript'
],
ignore: ['node_modules'],
sourceMaps: 'inline',
auxiliaryCommentBefore: ' istanbul ignore next '
}
module.exports = process.env.NODE_ENV === 'test' ? jestConfig : config