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