generated from ivandotv/nextjs-material-pwa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.babelrc.js
52 lines (45 loc) · 1.2 KB
/
.babelrc.js
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
const pkg = require('./package.json')
const { execSync } = require('child_process')
const pkgVersion = `${process.env.PKG_VERSION || pkg.version}`
const buildDate = execSync('git show -s --format=%ci HEAD')
.toString()
.replace(/[\r\n]+$/, '')
const commitSha =
process.env.VERCEL_GIT_COMMIT_SHA ||
execSync('git rev-parse --short HEAD')
.toString()
.replace(/[\r\n]+$/, '')
const branch =
process.env.VERCEL_GIT_COMMIT_REF ||
execSync(`git rev-parse --abbrev-ref HEAD`).toString()
const commitMessage =
process.env.VERCEL_GIT_COMMIT_MESSAGE ||
execSync(`git log -1 --pretty=%B`).toString()
const plugins = [
[
'transform-define',
{
__VERSION__: pkgVersion,
__DEV__: process.env.NODE_ENV !== 'production',
__BUILD_DATE__: buildDate,
__COMMIT_SHA__: commitSha,
__BRANCH__: branch,
__COMMIT_MESSAGE__: commitMessage
},
'@motion/babel-plugin'
]
]
if (process.env.NODE_ENV === 'production') {
plugins.push(['transform-remove-console', { exclude: ['error', 'warn'] }])
}
module.exports = {
presets: [
[
'next/babel',
{
'preset-react': { runtime: 'automatic', importSource: '@emotion/react' }
}
]
],
plugins
}