This repository has been archived by the owner on Nov 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 84
/
Copy pathrollup.config.js
128 lines (124 loc) · 3.7 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import postcss from 'rollup-plugin-postcss';
import autoprefixer from 'autoprefixer';
import cssnano from 'cssnano';
import nodeResolve from 'rollup-plugin-node-resolve';
import { eslint } from 'rollup-plugin-eslint';
import replace from 'rollup-plugin-replace';
import { string } from 'rollup-plugin-string';
import { terser } from 'rollup-plugin-terser';
import workerInline from 'rollup-plugin-worker-inline';
import { version, homepage } from './package.json';
const isProd = process.env.NODE_ENV === 'production';
const banner =
'/*!\n' +
` * FlvPlayer.js v${version}\n` +
` * Github: ${homepage}\n` +
` * (c) 2017-${new Date().getFullYear()} Harvey Zack\n` +
' * Released under the MIT License.\n' +
' */\n';
const baseConfig = {
output: {
format: 'umd',
sourcemap: !isProd,
},
plugins: [
eslint({
exclude: ['node_modules/**', 'src/decoder/video', 'src/control/style.scss', 'src/control/icons/*.svg'],
}),
string({
include: ['src/decoder/video/**/*.worker', 'src/control/icons/*.svg'],
}),
nodeResolve(),
commonjs(),
workerInline(),
babel({
runtimeHelpers: true,
exclude: 'node_modules/**',
presets: [
[
'@babel/preset-env',
{
modules: false,
},
],
],
plugins: ['@babel/plugin-external-helpers', '@babel/plugin-transform-runtime'],
}),
replace({
exclude: 'node_modules/**',
__ENV__: JSON.stringify(process.env.NODE_ENV || 'development'),
__VERSION__: version,
}),
isProd &&
terser({
output: {
preamble: banner,
comments: () => false,
},
}),
isProd && {
name: 'removeHtmlSpace',
transform(code) {
return {
code: code.replace(/\\n*\s*</g, '<').replace(/>\\n*\s*/g, '>'),
};
},
},
],
};
export default [
{
input: 'src/index.js',
output: {
name: 'FlvPlayer',
file: isProd ? 'dist/flvplayer.js' : 'docs/uncompiled/flvplayer.js',
},
plugins: [],
},
{
input: 'src/decoder/video/multiple/index.js',
output: {
name: 'FlvplayerDecoder',
file: isProd ? 'dist/flvplayer-decoder-multiple.js' : 'docs/uncompiled/flvplayer-decoder-multiple.js',
},
plugins: [],
},
{
input: 'src/decoder/video/baseline/index.js',
output: {
name: 'FlvplayerDecoder',
file: isProd ? 'dist/flvplayer-decoder-baseline.js' : 'docs/uncompiled/flvplayer-decoder-baseline.js',
},
plugins: [],
},
{
input: 'src/control/index.js',
output: {
name: 'FlvplayerControl',
file: isProd ? 'dist/flvplayer-control.js' : 'docs/uncompiled/flvplayer-control.js',
},
plugins: [
postcss({
plugins: [
autoprefixer(),
cssnano({
preset: 'default',
}),
],
sourceMap: !isProd,
extract: false,
}),
],
},
].map(config => {
return {
input: config.input,
output: {
...baseConfig.output,
...config.output,
},
plugins: [...baseConfig.plugins, ...config.plugins],
};
});