File tree 1 file changed +33
-24
lines changed
1 file changed +33
-24
lines changed Original file line number Diff line number Diff line change @@ -9,41 +9,50 @@ import {
9
9
terser ,
10
10
} from 'rollup-plugin-terser' ;
11
11
12
- const config = {
13
- input : 'src/index.js' ,
12
+ const plugins = [
13
+ globals ( ) ,
14
+ builtins ( ) ,
15
+ babel ( { exclude : 'node_modules/**' } ) ,
16
+ localResolve ( ) ,
17
+ resolve ( {
18
+ module : true ,
19
+ jsnext : true ,
20
+ main : true ,
21
+ preferBuiltins : true ,
22
+ browser : true ,
23
+ modulesOnly : true ,
24
+ } ) ,
25
+ terser ( ) ,
26
+ commonjs ( ) ,
27
+ filesize ( ) ,
28
+ ] ;
29
+
30
+ const createConfig = filename => ( {
31
+ input : `src/${ filename } .js` ,
14
32
output : [
15
33
{
16
- file : ' build/index .js' ,
34
+ file : ` build/${ filename } .js` ,
17
35
format : 'umd' ,
18
36
name : 'example-rollup-library' ,
19
37
} ,
20
38
{
21
- file : ' build/index .cjs.js' ,
39
+ file : ` build/${ filename } .cjs.js` ,
22
40
format : 'cjs' ,
23
41
name : 'example-rollup-library' ,
24
42
} ,
25
43
{
26
- file : ' build/index .esm.js' ,
44
+ file : ` build/${ filename } .esm.js` ,
27
45
format : 'es' ,
28
46
} ,
29
47
] ,
30
- plugins : [
31
- globals ( ) ,
32
- builtins ( ) ,
33
- babel ( { exclude : 'node_modules/**' } ) ,
34
- localResolve ( ) ,
35
- resolve ( {
36
- module : true ,
37
- jsnext : true ,
38
- main : true ,
39
- preferBuiltins : true ,
40
- browser : true ,
41
- modulesOnly : true ,
42
- } ) ,
43
- terser ( ) ,
44
- commonjs ( ) ,
45
- filesize ( ) ,
46
- ] ,
47
- } ;
48
+ plugins,
49
+ } ) ;
50
+
51
+ const configs = [
52
+ 'index' ,
53
+ 'a' ,
54
+ 'b' ,
55
+ 'c' ,
56
+ ] . map ( filename => createConfig ( filename ) ) ;
48
57
49
- export default config ;
58
+ export default configs ;
You can’t perform that action at this time.
0 commit comments