-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
42 lines (39 loc) · 970 Bytes
/
rollup.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
41
42
const { join } = require('path')
const buble = require('rollup-plugin-buble')
const typescript = require('rollup-plugin-typescript2')
const cwd = __dirname
const baseConfig = {
input: join(cwd, 'src/index.ts'),
external: ['react', 'nervjs', 'react-dom', 'vue', '@tarojs/shared', 'inversify'],
output: [
{
file: join(cwd, 'dist/index.js'),
format: 'cjs',
sourcemap: true,
exports: 'named'
}
],
plugins: [
typescript(),
buble()
]
}
const esmConfig = Object.assign({}, baseConfig, {
output: Object.assign({}, baseConfig.output, {
sourcemap: true,
format: 'es',
file: join(cwd, 'dist/runtime.esm.js')
}),
plugins: baseConfig.plugins.slice(0, baseConfig.plugins.length - 1)
})
function rollup () {
const target = process.env.TARGET
if (target === 'umd') {
return baseConfig
} else if (target === 'esm') {
return esmConfig
} else {
return [esmConfig]
}
}
module.exports = rollup()