-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
61 lines (57 loc) · 1.39 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
import resolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
import {terser} from 'rollup-plugin-terser'
import babel from 'rollup-plugin-babel'
import {version, author, repository} from './package.json'
const compress = process.env.NODE_ENV === 'production'
const banner =
`/*!
* img-lazy-processor.js v${version}
* (c) 2019-${new Date().getFullYear()} ${author}
* ${repository.url.replace('git+', '')}
* Released under the MIT License.
*/
`
const config = {
input: 'src/index.js',
output: !compress ? [{
file: 'dist/img-lazy-processor.js',
format: 'umd',
name: 'ImgLazyProcessor',
banner,
}, {
file: 'dist/img-lazy-processor.esm.js',
format: 'es',
name: 'ImgLazyProcessor',
banner,
}, {
file: 'dist/img-lazy-processor.common.js',
format: 'cjs',
name: 'ImgLazyProcessor',
banner,
}] : [{
file: 'dist/img-lazy-processor.min.js',
format: 'umd',
name: 'ImgLazyProcessor',
sourcemap: true,
banner,
}],
plugins: [
resolve(),
babel({
exclude: 'node_modules/**', // 只编译源代码
}),
commonjs(),
...(compress ? [terser({
compress: {
pure_funcs: ['console.log'],
pure_getters: true,
unsafe: true,
unsafe_comps: true,
warnings: false,
},
// sourcemap: true, // isError
})] : []),
],
}
export default config