@@ -7,7 +7,6 @@ const express = require('express');
7
7
const JsWriter = require ( '@asset-pipe/js-writer' ) ;
8
8
const CssWriter = require ( '@asset-pipe/css-writer' ) ;
9
9
const emits = require ( 'emits' ) ;
10
- const { Transform } = require ( 'stream' ) ;
11
10
12
11
module . exports = class Middleware extends EventEmitter {
13
12
constructor ( jsFiles = [ ] , cssFiles = [ ] , options = { } ) {
@@ -27,7 +26,7 @@ module.exports = class Middleware extends EventEmitter {
27
26
this . emits = emits ;
28
27
this . writers = {
29
28
js : new JsWriter ( jsFiles , this . options , true ) ,
30
- css : new CssWriter ( cssFiles , this . options ) ,
29
+ css : new CssWriter ( cssFiles , true ) ,
31
30
} ;
32
31
33
32
this . writers . js . plugin ( watchify ) ;
@@ -43,16 +42,6 @@ module.exports = class Middleware extends EventEmitter {
43
42
bundler . pipe ( devnull ( ) ) ;
44
43
} ) ;
45
44
46
- this . writers . css . on ( 'update' , ( ) => {
47
- const bundler = this . writers . css ;
48
-
49
- bundler . on ( 'error' , e => {
50
- this . emit ( 'error' , e ) ;
51
- } ) ;
52
-
53
- bundler . pipe ( devnull ( ) ) ;
54
- } ) ;
55
-
56
45
// Proxy underlaying events
57
46
this . writers . js . on ( 'error' , this . emits ( 'error' ) ) ;
58
47
this . writers . js . on ( 'update' , this . emits ( 'update' ) ) ;
@@ -61,10 +50,6 @@ module.exports = class Middleware extends EventEmitter {
61
50
this . writers . js . on ( 'log' , this . emits ( 'log' ) ) ;
62
51
63
52
this . writers . css . on ( 'error' , this . emits ( 'error' ) ) ;
64
- this . writers . css . on ( 'update' , this . emits ( 'update' ) ) ;
65
- this . writers . css . on ( 'bytes' , this . emits ( 'bytes' ) ) ;
66
- this . writers . css . on ( 'time' , this . emits ( 'time' ) ) ;
67
- this . writers . css . on ( 'log' , this . emits ( 'log' ) ) ;
68
53
69
54
// eslint-disable-next-line new-cap
70
55
this . app = express . Router ( {
@@ -117,14 +102,7 @@ module.exports = class Middleware extends EventEmitter {
117
102
css ( ) {
118
103
return ( req , res , next ) => {
119
104
res . type ( 'css' ) ;
120
- const bundler = this . writers . css . pipe (
121
- new Transform ( {
122
- objectMode : true ,
123
- transform ( chunk , enc , cb ) {
124
- cb ( null , chunk . content ) ;
125
- } ,
126
- } )
127
- ) ;
105
+ const bundler = this . writers . css . bundle ( ) ;
128
106
129
107
bundler . on ( 'error' , cleanup ) ;
130
108
0 commit comments