-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.ts
53 lines (49 loc) · 1.33 KB
/
rollup.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
48
49
50
51
52
53
import { execSync } from "child_process";
import replace from "@rollup/plugin-replace";
import typescript from "@rollup/plugin-typescript";
import terser from "@rollup/plugin-terser";
import json from "@rollup/plugin-json";
import process from "process";
import { defineConfig } from "rollup";
import pkg from "./package.json" assert { type: "json" };
const command = 'git describe --always --tags --long --match "v*" --dirty';
const GIT_VERSION = execSync(command).toString().trim();
const BUILD_INFO = `${GIT_VERSION}(${new Date().toLocaleString()})`;
const isDev = process.env.BUILD === "development";
const config = defineConfig({
input: "index.ts",
output: [
{
file: pkg.main,
name: "KitMathExpression",
format: "umd",
sourcemap: false,
banner: `/** reskit-math-expression-${BUILD_INFO} **/`,
},
{
file: pkg.module,
format: "esm",
sourcemap: false,
banner: `/** reskit-math-expression-${BUILD_INFO} **/`,
},
],
external: [
...Object.keys({
...pkg.dependencies,
}),
],
plugins: [
replace({
preventAssignment: true,
__VERSION__: pkg.version,
__BUILD_INFO__: BUILD_INFO,
__DEV__: String(isDev),
}),
json(),
typescript({
tsconfig: "tsconfig.json",
}),
!isDev && terser(),
],
});
export default config;