forked from nervosnetwork/ckb-js-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
57 lines (54 loc) · 1.47 KB
/
rollup.config.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
53
54
55
56
57
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import replace from "@rollup/plugin-replace";
import { terser } from "rollup-plugin-terser";
import * as package_json from "./package.json";
const isProduction = process.env.BUILD === 'production';
const outputFolder = isProduction ? "dist" : "build";
const sourcemap = !isProduction;
module.exports = [
{
input: "src/index.js",
output: {
file: outputFolder + "/ckb-js-toolkit.node.js",
format: "cjs",
sourcemap: true
},
plugins: [
replace({__development_build__: package_json.version}),
resolve({preferBuiltins: true}),
commonjs(),
isProduction && terser()
]
},
// TODO: do we need sourcemap for UMD and ESM versions?
{
input: "src/index.js",
output: {
file: outputFolder + "/ckb-js-toolkit.umd.js",
format: "umd",
name: "CKBJSToolkit",
sourcemap: sourcemap
},
plugins: [
replace({__development_build__: package_json.version}),
resolve({browser: true, preferBuiltins: false}),
commonjs(),
isProduction && terser()
]
},
{
input: "src/index.js",
output: {
file: outputFolder + "/ckb-js-toolkit.esm.js",
format: "esm",
sourcemap: sourcemap
},
plugins: [
replace({__development_build__: package_json.version}),
resolve({browser: true, preferBuiltins: false}),
commonjs(),
isProduction && terser()
]
}
];