forked from Donaldcwl/browser-image-compression
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
62 lines (59 loc) · 1.43 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
53
54
55
56
57
58
59
60
61
62
import babel from 'rollup-plugin-babel'
import { terser } from 'rollup-plugin-terser'
import nodent from 'rollup-plugin-nodent'
import license from 'rollup-plugin-license'
import copy from 'rollup-plugin-copy'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import path from 'path'
const pkg = require('./package.json')
const notExternal = [
// 'pako',
'uzip'
]
const external = Object.keys(pkg.dependencies).filter(value => !notExternal.includes(value))
let plugins = [
nodent({ noRuntime: true, promises: true }),
babel(),
terser({
keep_fnames: true,
mangle: { reserved: ['CustomFile', 'CustomFileReader', 'UPNG', 'UZIP'] }
}),
license({
sourcemap: true,
banner: '<%= _.startCase(pkg.name) %>\nv<%= pkg.version %>\nby <%= pkg.author %>\n<%= pkg.repository.url %>',
}),
copy({
targets: [
{ src: 'lib/index.d.ts', dest: path.dirname(pkg.types) , rename: path.basename(pkg.types) }
]
}),
nodeResolve(),
commonjs()
]
export default {
input: 'lib/index.js',
plugins: plugins,
external: external,
output: [
{
file: pkg.main,
name: 'imageCompression',
format: 'umd',
sourcemap: true,
globals: {
// pako: 'pako',
uzip: 'UZIP'
}
},
{
file: pkg.module,
format: 'es',
sourcemap: true,
globals: {
// pako: 'pako',
uzip: 'UZIP'
}
}
]
}