-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.config.ts
47 lines (44 loc) · 1.29 KB
/
build.config.ts
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
// build.config.ts
import { defineBuildConfig } from 'unbuild'
import { babel } from '@rollup/plugin-babel'
export default defineBuildConfig({
replace: {
'import.meta.vitest': 'undefined',
},
hooks: {
'rollup:options'(_ctx, options) {
if (!Array.isArray(options.plugins)) {
if (options.plugins != null && typeof options.plugins !== 'boolean') {
options.plugins = [options.plugins]
} else {
options.plugins = []
}
}
for (let i = 0, l = options.plugins.length; i < l; i++) {
const plugin = options.plugins[i]
if (
typeof plugin === 'object' &&
plugin != null &&
!Array.isArray(plugin) &&
!('then' in plugin)
) {
if (plugin.name === 'esbuild') {
options.plugins[i] = babel({
babelHelpers: 'bundled',
extensions: ['.ts', '.js', '.cjs', '.mjs', '.es', '.es6'],
presets: [
'@babel/preset-typescript',
[
'@babel/preset-env',
{
targets: '>= .3% and not dead, node > 16',
},
],
],
})
}
}
}
},
},
})