@@ -4,7 +4,6 @@ import utils from 'rollup-pluginutils';
4
4
5
5
export default opts => {
6
6
let styles = { } ;
7
- let bundles = { } ;
8
7
9
8
const options = Object . assign (
10
9
{
@@ -30,30 +29,28 @@ export default opts => {
30
29
return '' ;
31
30
} ,
32
31
33
- ongenerate ( opts , bundle ) {
34
- // Depending on the Rollup version,
35
- // the `modules` will be either an array
36
- // or an object with key-value pairs.
37
- let modules = Array . isArray ( bundle . modules )
38
- ? bundle . modules
39
- : Object . getOwnPropertyNames ( bundle . modules ) ;
40
- let css = Object . entries ( styles )
41
- . sort ( ( a , b ) => modules . indexOf ( a [ 0 ] ) - modules . indexOf ( b [ 0 ] ) )
42
- . map ( entry => entry [ 1 ] )
43
- . join ( '\n' ) ;
44
- bundles [ opts . file ] = css ;
45
- } ,
46
-
47
- onwrite ( opts ) {
48
- fs . outputFile (
49
- options . output ||
32
+ generateBundle ( opts , bundle ) {
33
+ for ( const file in bundle ) {
34
+ // Depending on the Rollup version,
35
+ // the `modules` will be either an array
36
+ // or an object with key-value pairs.
37
+ let modules = Array . isArray ( bundle [ file ] . modules )
38
+ ? bundle [ file ] . modules
39
+ : Object . getOwnPropertyNames ( bundle [ file ] . modules ) ;
40
+ let css = Object . entries ( styles )
41
+ . sort ( ( a , b ) => modules . indexOf ( a [ 0 ] ) - modules . indexOf ( b [ 0 ] ) )
42
+ . map ( entry => entry [ 1 ] )
43
+ . join ( '\n' ) ;
44
+
45
+ fs . outputFile (
46
+ options . output ||
50
47
path . join (
51
48
path . dirname ( opts . file ) ,
52
- path . basename ( opts . file , path . extname ( opts . file ) ) +
53
- '.css'
49
+ path . basename ( file , path . extname ( opts . file ) ) + '.css'
54
50
) ,
55
- bundles [ opts . file ]
56
- ) ;
51
+ css
52
+ ) ;
53
+ }
57
54
}
58
55
} ;
59
56
} ;
0 commit comments