aboutsummaryrefslogtreecommitdiffhomepage
path: root/rollup.config.js
diff options
context:
space:
mode:
authorHsieh Chin Fan <pham@topo.tw>2024-10-02 10:12:46 +0800
committerHsieh Chin Fan <pham@topo.tw>2024-10-02 10:12:46 +0800
commit1c7e77b8546ac32b8176ab54dd06ede6ba7deb55 (patch)
treeca0d50e7b8b3dcbd2cc8891786dca32f1face931 /rollup.config.js
parentb7e898bc9022a6d7caef705ee2764c139ec86299 (diff)
style: switch to standardjs
Diffstat (limited to 'rollup.config.js')
-rw-r--r--rollup.config.js54
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 @@
1import node from '@rollup/plugin-node-resolve'; 1import node from '@rollup/plugin-node-resolve'
2import commonjs from '@rollup/plugin-commonjs'; 2import commonjs from '@rollup/plugin-commonjs'
3import terser from '@rollup/plugin-terser'; 3import terser from '@rollup/plugin-terser'
4import { existsSync } from 'fs'; 4import { existsSync } from 'fs'
5import { join } from 'path'; 5import { join } from 'path'
6import { bundleStats } from 'rollup-plugin-bundle-stats'; 6import { bundleStats } from 'rollup-plugin-bundle-stats'
7 7
8const production = !process.env.ROLLUP_WATCH; 8const production = !process.env.ROLLUP_WATCH
9 9
10const general = { 10const 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
61export default [ 61export 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/))