-
Notifications
You must be signed in to change notification settings - Fork 2
/
microbundle.config.js
40 lines (37 loc) · 1.09 KB
/
microbundle.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
module.exports = {
plugins: {
typescript: function (config) {
// Since imported *.svg will be transformed to ES modules by the image plugin, tell
// TypeScript to process them
return {
...config,
include: ['*.ts+(|x)', '**/*.ts+(|x)', '*.s?css', '*.svg', '**/*.svg'],
objectHashIgnoreUnknownHack: true,
}
},
},
config: function (config, context) {
const {
format,
options: { pkg },
} = context
// When building browser "standalone" bundles, make sure we inline dependencies
if (format === 'umd') {
const _external = config.inputOptions.external
config.inputOptions.external = (id, ...args) => {
if (
id in (pkg.dependencies || {}) ||
id in (pkg.peerDependencies || {}) ||
// react imports internal modules that we need inlined into the lib as well
id.match(/^react\//) ||
id.match(/\.svg$/)
) {
return false
}
return _external(id, ...args)
}
config.inputOptions.cache = false
}
return config
},
}