Skip to content

Commit 1cdde66

Browse files
committed
[更改] 让 Babel 转换 import.meta.url 的插件只在单元测试的环境生效
1 parent 02f961e commit 1cdde66

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

babel.config.cjs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
const test = process.env.NODE_ENV === 'test'
2+
13
module.exports = {
24
presets: [
35
['@babel/preset-env', { targets: { node: 'current' } }],
46
'@babel/preset-typescript'
57
],
68
plugins: [
7-
'babel-plugin-transform-import-meta'
9+
...(test ? ['babel-plugin-transform-import-meta'] : [])
810
]
911
}

0 commit comments

Comments
 (0)