diff options
Diffstat (limited to 'scripts/rollup.config.js')
-rw-r--r-- | scripts/rollup.config.js | 29 |
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' | |||
6 | import { bundleStats } from 'rollup-plugin-bundle-stats' | 6 | import { bundleStats } from 'rollup-plugin-bundle-stats' |
7 | 7 | ||
8 | const prod = process.env.PRODUCTION | 8 | const prod = process.env.PRODUCTION |
9 | const addon = process.env.ADDON | 9 | const watch = process.env.ROLLUP_WATCH |
10 | 10 | ||
11 | function resolve (file, origin) { | 11 | function 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 | }) | ||