aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/rollup.config.js
diff options
context:
space:
mode:
authorHsieh Chin Fan <pham@topo.tw>2024-11-04 23:17:18 +0800
committerHsieh Chin Fan <pham@topo.tw>2024-11-04 23:17:18 +0800
commitc4c8903b148ce75dd2470203e9faf93e3a42b15b (patch)
treeba8684d5edaf0b897da85b1a70e1fededdefbaca /scripts/rollup.config.js
parent9d9fb5652086dad99f9b0f4b32b57b49568a5ead (diff)
parent71810f684724245f17b5cee72be030f4a2467cca (diff)
Merge branch 'addon'
Diffstat (limited to 'scripts/rollup.config.js')
-rw-r--r--scripts/rollup.config.js29
1 files changed, 2 insertions, 27 deletions
diff --git a/scripts/rollup.config.js b/scripts/rollup.config.js
index 547260b..b3a6139 100644
--- a/scripts/rollup.config.js
+++ b/scripts/rollup.config.js
@@ -6,7 +6,7 @@ import { join } from 'path'
6import { bundleStats } from 'rollup-plugin-bundle-stats' 6import { bundleStats } from 'rollup-plugin-bundle-stats'
7 7
8const prod = process.env.PRODUCTION 8const prod = process.env.PRODUCTION
9const addon = process.env.ADDON 9const watch = process.env.ROLLUP_WATCH
10 10
11function resolve (file, origin) { 11function resolve (file, origin) {
12 // Your way to resolve local include path 12 // Your way to resolve local include path
@@ -79,31 +79,6 @@ export default [
79] 79]
80 .map(config => ({ ...general, ...config })) 80 .map(config => ({ ...general, ...config }))
81 .filter(config => { 81 .filter(config => {
82 if (addon) return config.input.match(/dumbymap/) 82 if (watch) return config.input.match(/editor/)
83 if (!prod) return config.input.match(/editor/)
84 return true 83 return true
85 }) 84 })
86 .map(config => {
87 if (!addon) return config
88
89 config.output.forEach(o => { o.dir = './addon' })
90 config.plugins.push({
91 name: 'remove-exports',
92 transform (code, id) {
93 if (id.includes(config.input)) {
94 // remove export keyword for addon
95 const transformedCode = code.replace(/\n(\s*)export\s*/g, '$1')
96 return {
97 code: [
98 transformedCode,
99 'globalThis.generateMaps = generateMaps',
100 'globalThis.mapclay = mapclay',
101 ].join('\n'),
102 }
103 }
104 return null
105 },
106 })
107
108 return config
109 })