From 15a939d234910016d36d4297ec14de51c96168ce Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Tue, 13 Aug 2024 23:58:38 +0800 Subject: Initial Commit --- rollup.config.js | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 rollup.config.js (limited to 'rollup.config.js') 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 @@ +import node from '@rollup/plugin-node-resolve'; +import commonjs from '@rollup/plugin-commonjs'; +import terser from '@rollup/plugin-terser'; +import { existsSync } from 'fs'; +import { join } from 'path'; + +const production = !process.env.ROLLUP_WATCH; +const general = { + output: [ + { + dir: './dist', + format: 'esm', + entryFileNames: '[name].mjs', + } + ], + watch: { + clearScreen: false, + include: ["src/**", "mapclay/dist/mapclay.mjs"] + }, + context: "window", + plugins: [ + { + name: 'leader-line', + transform(code, id) { + if (id.includes('node_modules/leader-line/')) { + return `${code}\nexport default LeaderLine;`; + } + return null; + }, + }, + { + name: 'mapclay', + resolveId(source) { + if (source === 'mapclay' && existsSync(join('.', 'mapclay'))) { + return './mapclay/dist/mapclay.mjs'; + } + return null; + } + }, + node(), + commonjs(), + production && terser(), + ], +} + +export default [ + { + input: "src/editor.mjs", + }, + { + input: "src/dumbymap.mjs", + }, +].map(config => { + return { ...general, ...config } +}) -- cgit v1.2.3-70-g09d2