-
Notifications
You must be signed in to change notification settings - Fork 164
/
rollup.config.js
110 lines (106 loc) · 2.37 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import babel from 'rollup-plugin-babel'
import { terser } from 'rollup-plugin-terser'
import license from 'rollup-plugin-license'
import replace from 'rollup-plugin-replace'
import { uglify } from 'rollup-plugin-uglify'
import postcss from 'rollup-plugin-postcss'
import filesize from 'rollup-plugin-filesize'
import cssnano from 'cssnano'
import pkg from './package.json'
const banner = `/*! ${pkg.name} ${pkg.version} | ${pkg.license} License | https://github.com/${pkg.repository} */`
const sharedPlugins = [
postcss({
extensions: ['.css'],
plugins: [cssnano()],
}),
replace({
__TEST__: process.env.NODE_ENV === 'test' ? 'true' : 'false',
}),
babel({
exclude: 'node_modules/**',
plugins: ['external-helpers', 'transform-object-rest-spread'],
}),
filesize({
showMinifiedSize: false,
showGzippedSize: true,
}),
]
const prettifyPlugin = uglify({
compress: false,
mangle: false,
output: {
beautify: true,
indent_level: 2,
preamble: banner,
},
})
export default [
{
input: 'src/index.js',
output: {
file: pkg.module,
format: 'es',
},
plugins: [...sharedPlugins, license({ banner })],
},
{
input: 'src/index.js',
output: {
name: 'mediumZoom',
file: pkg.main.replace('.min', ''),
format: 'umd',
},
plugins: [...sharedPlugins, prettifyPlugin],
},
{
input: 'src/index.js',
output: {
name: 'mediumZoom',
file: pkg.main,
format: 'umd',
},
plugins: [...sharedPlugins, terser(), license({ banner })],
},
// pure
{
input: 'src/medium-zoom.js',
output: {
file: 'dist/pure/index.js',
format: 'es',
},
plugins: [...sharedPlugins, license({ banner })],
},
{
input: 'src/medium-zoom.js',
output: {
name: 'mediumZoom',
file: 'dist/pure/medium-zoom.umd.js',
format: 'umd',
},
plugins: [...sharedPlugins, prettifyPlugin],
},
{
input: 'src/medium-zoom.js',
output: {
name: 'mediumZoom',
file: 'dist/pure/medium-zoom.min.umd.js',
format: 'umd',
},
plugins: [...sharedPlugins, terser(), license({ banner })],
},
// style
{
input: 'src/medium-zoom.css',
output: {
file: 'dist/style.css',
format: 'es',
},
plugins: [
postcss({
extract: true,
minimize: true,
}),
license({ banner }),
],
},
]