diff options
author | Hsieh Chin Fan <pham@topo.tw> | 2024-10-10 12:45:44 +0800 |
---|---|---|
committer | Hsieh Chin Fan <pham@topo.tw> | 2024-10-10 13:04:18 +0800 |
commit | 89ca84e47d4958e064b682405e94a3270fc99338 (patch) | |
tree | f01c5fb25e5fd4f25db874c371244c0c92d50a5b /rollup.config.js | |
parent | eaf2639b3c9269b9222bfcd993b7b7a3980f1b2a (diff) |
chore: move config files about dev into scripts/
Diffstat (limited to 'rollup.config.js')
-rw-r--r-- | rollup.config.js | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/rollup.config.js b/rollup.config.js deleted file mode 100644 index f5a22eb..0000000 --- a/rollup.config.js +++ /dev/null | |||
@@ -1,72 +0,0 @@ | |||
1 | import node from '@rollup/plugin-node-resolve' | ||
2 | import commonjs from '@rollup/plugin-commonjs' | ||
3 | import terser from '@rollup/plugin-terser' | ||
4 | import { existsSync } from 'fs' | ||
5 | import { join } from 'path' | ||
6 | import { bundleStats } from 'rollup-plugin-bundle-stats' | ||
7 | |||
8 | const production = !process.env.ROLLUP_WATCH | ||
9 | |||
10 | const general = { | ||
11 | output: [ | ||
12 | { | ||
13 | dir: './dist', | ||
14 | format: 'esm', | ||
15 | entryFileNames: '[name].mjs', | ||
16 | sourcemap: 'true', | ||
17 | }, | ||
18 | ], | ||
19 | watch: { | ||
20 | clearScreen: false, | ||
21 | include: ['src/**', 'mapclay/dist/mapclay.mjs'], | ||
22 | }, | ||
23 | context: 'window', | ||
24 | plugins: [ | ||
25 | { | ||
26 | name: 'watch-mapclay', | ||
27 | buildStart () { | ||
28 | const mapclayPath = join(process.cwd(), 'mapclay', 'dist', 'mapclay.mjs') | ||
29 | if (existsSync(mapclayPath)) { | ||
30 | this.addWatchFile(mapclayPath) | ||
31 | } else { | ||
32 | console.warn('mapclay.mjs not found at:', mapclayPath) | ||
33 | } | ||
34 | }, | ||
35 | }, | ||
36 | { | ||
37 | name: 'leader-line', | ||
38 | transform (code, id) { | ||
39 | if (id.includes('node_modules/leader-line/')) { | ||
40 | return `${code}\nexport default LeaderLine;` | ||
41 | } | ||
42 | return null | ||
43 | }, | ||
44 | }, | ||
45 | { | ||
46 | name: 'mapclay', | ||
47 | resolveId (source) { | ||
48 | if (source === 'mapclay' && existsSync(join('.', 'mapclay'))) { | ||
49 | return './mapclay/dist/mapclay.mjs' | ||
50 | } | ||
51 | return null | ||
52 | }, | ||
53 | }, | ||
54 | node(), | ||
55 | commonjs(), | ||
56 | production && terser({ | ||
57 | keep_fnames: true, | ||
58 | }), | ||
59 | production && bundleStats(), | ||
60 | ], | ||
61 | } | ||
62 | |||
63 | export default [ | ||
64 | { | ||
65 | input: 'src/editor.mjs', | ||
66 | }, | ||
67 | { | ||
68 | input: 'src/dumbymap.mjs', | ||
69 | }, | ||
70 | ] | ||
71 | .map(config => ({ ...general, ...config })) | ||
72 | .filter((config) => production || config.input.match(/editor/)) | ||