aboutsummaryrefslogtreecommitdiffhomepage
path: root/rollup.config.js
diff options
context:
space:
mode:
Diffstat (limited to 'rollup.config.js')
-rw-r--r--rollup.config.js55
1 files changed, 55 insertions, 0 deletions
diff --git a/rollup.config.js b/rollup.config.js
new file mode 100644
index 0000000..1dc3a02
--- /dev/null
+++ b/rollup.config.js
@@ -0,0 +1,55 @@
1import node from '@rollup/plugin-node-resolve';
2import commonjs from '@rollup/plugin-commonjs';
3import terser from '@rollup/plugin-terser';
4import { existsSync } from 'fs';
5import { join } from 'path';
6
7const production = !process.env.ROLLUP_WATCH;
8const general = {
9 output: [
10 {
11 dir: './dist',
12 format: 'esm',
13 entryFileNames: '[name].mjs',
14 }
15 ],
16 watch: {
17 clearScreen: false,
18 include: ["src/**", "mapclay/dist/mapclay.mjs"]
19 },
20 context: "window",
21 plugins: [
22 {
23 name: 'leader-line',
24 transform(code, id) {
25 if (id.includes('node_modules/leader-line/')) {
26 return `${code}\nexport default LeaderLine;`;
27 }
28 return null;
29 },
30 },
31 {
32 name: 'mapclay',
33 resolveId(source) {
34 if (source === 'mapclay' && existsSync(join('.', 'mapclay'))) {
35 return './mapclay/dist/mapclay.mjs';
36 }
37 return null;
38 }
39 },
40 node(),
41 commonjs(),
42 production && terser(),
43 ],
44}
45
46export default [
47 {
48 input: "src/editor.mjs",
49 },
50 {
51 input: "src/dumbymap.mjs",
52 },
53].map(config => {
54 return { ...general, ...config }
55})