-
Notifications
You must be signed in to change notification settings - Fork 15
/
rollup.config.mjs
90 lines (86 loc) · 2.52 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import terser from "@rollup/plugin-terser";
import json from "@rollup/plugin-json";
import commonjs from "@rollup/plugin-commonjs";
import replace from '@rollup/plugin-replace';
import {nodeResolve} from "@rollup/plugin-node-resolve";
import typescript from 'rollup-plugin-typescript2';
import css from "rollup-plugin-css-only";
import deepmerge from "deepmerge";
/* import fs from "fs";
import path from "path"; */
import pkg from "./package.json" with { type: "json" };
const defaultConfig = {
input: "src/index.ts",
output: {
format: "umd",
name: "MiragonModeler",
globals: {
react: "React",
"monaco-editor": "monaco",
"bpmn-js/lib/Modeler": "BpmnJS",
"dmn-js/lib/Modeler": "DmnJS"
}
},
external: [
...Object.keys(pkg.peerDependencies || {}),
"monaco-editor",
// "react",
"bpmn-js/lib/Modeler",
"dmn-js/lib/Modeler"
],
plugins: [
replace({
values: {
'process.env.NODE_ENV': JSON.stringify('production')
},
preventAssignment: true
}),
nodeResolve({
mainFields: [
'browser',
'module',
'main'
]
}),
commonjs({
exclude: ["src/**"],
include: ["node_modules/**"]
}),
json(),
typescript(),
css({output: "bundle.css"})
]
};
export default [
/* deepmerge(defaultConfig, {
output: {
file: "dist/bundle.js"
}
}), */
deepmerge(defaultConfig, {
output: {
file: "dist/bundle.min.js",
sourcemap: true
},
plugins: [
terser(),
/* { // Use this to write a graph.json to analyze the bundle
// Remember to uncomment the imports, too
buildEnd() {
const deps = [];
for (const id of this.getModuleIds()) {
const m = this.getModuleInfo(id);
if (m != null && !m.isExternal) {
for (const target of m.importedIds) {
deps.push({source: m.id, target})
}
}
}
fs.writeFileSync(
path.join(__dirname, 'graph.json'),
JSON.stringify(deps, null, 2));
},
} */
]
})
];