forked from aidenybai/million
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.config.ts
43 lines (41 loc) · 1.11 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
import { defineBuildConfig } from 'unbuild';
import banner from 'rollup-plugin-banner2';
import replace from '@rollup/plugin-replace';
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
const version = JSON.parse(
readFileSync(join(__dirname, 'package.json'), 'utf-8'),
).version;
export default defineBuildConfig({
entries: [
'./packages/million',
'./packages/jsx-runtime',
'./packages/compiler',
'./packages/react',
'./packages/react-server',
'./packages/preact',
'./packages/preact-server',
'./packages/types',
],
declaration: true,
clean: true,
failOnWarn: false,
rollup: {
emitCJS: true,
inlineDependencies: true,
},
hooks: {
'rollup:options'(_ctx, options) {
if (Array.isArray(options?.plugins)) {
options.plugins.push(banner(() => `'use client';\n`));
options.plugins.push(
replace({
'process.env.VERSION': JSON.stringify(version),
preventAssignment: true,
}),
);
}
},
},
externals: ['react', 'react-dom', 'preact', 'million', 'vite', 'esbuild'],
});