-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrollup.config.js
52 lines (46 loc) · 1.29 KB
/
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
43
44
45
46
47
48
49
50
51
52
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import babel from '@rollup/plugin-babel'
import { terser } from 'rollup-plugin-terser'
const pkg = require('./package')
const banner = (() => {
const id = `${pkg.name} v${pkg.version}`
const homepage = 'github.com/' + pkg.repository
const license = `${pkg.license} License`
return `/*! ${id} | ${homepage} | ${license} */`
})()
function outputConfig(config) {
const defaultConfig = {
sourcemap: true,
banner,
}
return Object.assign(defaultConfig, config)
}
function umdConfig(config) {
const defaultConfig = {
name: 'DexieBatch',
format: 'umd',
globals: { dexie: 'Dexie' },
}
return outputConfig(Object.assign(defaultConfig, config))
}
const babelConfig = {
babelHelpers: 'bundled',
exclude: 'node_modules/**',
presets: [['@babel/env', { targets: { browsers: 'defaults' } }]],
}
export default {
input: 'dexie-batch.js',
output: [
// Browser-friendly UMD build
umdConfig({ file: pkg.main }),
umdConfig({
file: pkg.main.replace(/\.js$/, '.min.js'),
plugins: [terser()],
}),
// ECMAScript module build
outputConfig({ file: pkg.module, format: 'es' }),
],
external: ['dexie'],
plugins: [resolve(), commonjs(), babel(babelConfig)],
}