@@ -4,7 +4,6 @@ import utils from 'rollup-pluginutils';
44
55export default opts => {
66 let styles = { } ;
7- let bundles = { } ;
87
98 const options = Object . assign (
109 {
@@ -30,30 +29,28 @@ export default opts => {
3029 return '' ;
3130 } ,
3231
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 ||
5047 path . join (
5148 path . dirname ( opts . file ) ,
52- path . basename ( opts . file , path . extname ( opts . file ) ) +
53- '.css'
49+ path . basename ( file , path . extname ( opts . file ) ) + '.css'
5450 ) ,
55- bundles [ opts . file ]
56- ) ;
51+ css
52+ ) ;
53+ }
5754 }
5855 } ;
5956} ;
0 commit comments