-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathrollup.config.mjs
42 lines (37 loc) · 1.06 KB
/
rollup.config.mjs
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
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import terser from "@rollup/plugin-terser";
import typescript from "rollup-plugin-typescript2";
import yargs from "yargs";
const { argv } = yargs(process.argv);
const format = argv.format || argv.f || "iife";
const compress = argv.environment === "production";
const fileName = "index";
const outputRoot = "lib";
const hasMinFile = compress ? ".min" : "";
const file = {
amd: `${outputRoot}/amd/${fileName}.${hasMinFile}.js`,
umd: `${outputRoot}/umd/${fileName}.${hasMinFile}.js`,
iife: `${outputRoot}/iife/${fileName}.${hasMinFile}.js`,
cjs: `${outputRoot}/commonjs/${fileName}.${hasMinFile}.js`,
es: `${outputRoot}/es/${fileName}.${hasMinFile}.js`,
}[format];
export default {
input: "./src/index.ts",
output: {
name: "disable-devtool",
file,
format,
compact: true,
sourcemap: true,
extend: true,
},
plugins: [
resolve(),
commonjs(),
typescript({
tsconfig: "tsconfig.json",
}),
compress && terser(),
],
};