@@ -4,10 +4,9 @@ const EventEmitter = require('events');
44const watchify = require ( 'watchify' ) ;
55const devnull = require ( 'dev-null' ) ;
66const express = require ( 'express' ) ;
7- const JsWriter = require ( 'asset-pipe- js-writer' ) ;
8- const CssWriter = require ( 'asset-pipe- css-writer' ) ;
7+ const JsWriter = require ( '@ asset-pipe/ js-writer' ) ;
8+ const CssWriter = require ( '@ asset-pipe/ css-writer' ) ;
99const emits = require ( 'emits' ) ;
10- const { Transform } = require ( 'stream' ) ;
1110
1211module . exports = class Middleware extends EventEmitter {
1312 constructor ( jsFiles = [ ] , cssFiles = [ ] , options = { } ) {
@@ -27,7 +26,7 @@ module.exports = class Middleware extends EventEmitter {
2726 this . emits = emits ;
2827 this . writers = {
2928 js : new JsWriter ( jsFiles , this . options , true ) ,
30- css : new CssWriter ( cssFiles , this . options ) ,
29+ css : new CssWriter ( cssFiles , true ) ,
3130 } ;
3231
3332 this . writers . js . plugin ( watchify ) ;
@@ -43,16 +42,6 @@ module.exports = class Middleware extends EventEmitter {
4342 bundler . pipe ( devnull ( ) ) ;
4443 } ) ;
4544
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-
5645 // Proxy underlaying events
5746 this . writers . js . on ( 'error' , this . emits ( 'error' ) ) ;
5847 this . writers . js . on ( 'update' , this . emits ( 'update' ) ) ;
@@ -61,10 +50,6 @@ module.exports = class Middleware extends EventEmitter {
6150 this . writers . js . on ( 'log' , this . emits ( 'log' ) ) ;
6251
6352 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' ) ) ;
6853
6954 // eslint-disable-next-line new-cap
7055 this . app = express . Router ( {
@@ -117,14 +102,7 @@ module.exports = class Middleware extends EventEmitter {
117102 css ( ) {
118103 return ( req , res , next ) => {
119104 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 ( ) ;
128106
129107 bundler . on ( 'error' , cleanup ) ;
130108
0 commit comments