@@ -18,7 +18,7 @@ module.exports = function (gulp, $, options) {
1818 const fixturesPath = path . join ( process . cwd ( ) , options . paths . src . fixtures ) ;
1919
2020
21- var userRefPipe ; //eslint-disable-line no-var
21+ var useRef ; //eslint-disable-line no-var
2222
2323
2424 baseData . PRODUCTION = options . production ;
@@ -59,15 +59,16 @@ module.exports = function (gulp, $, options) {
5959
6060 const styleFilter = $ . filter ( '**/*.min.css' , { restore : true } ) ;
6161 const jsFilter = $ . filter ( '**/*.min.js' , { restore : true } ) ;
62+ const assetsFilter = $ . filter ( [ '**/*.*' , '!**/' + options . viewmatch ] , { restore : true } ) ;
6263
63- userRefPipe = require ( 'lazypipe' ) ( )
64+ useRef = require ( 'lazypipe' ) ( )
6465 . pipe ( $ . useref , {
6566 types : [ 'css' , 'js' , 'replace' , 'remove' ] ,
6667 searchPath : [ paths . dist . root , paths . tmp ] ,
6768 //just replace src
68- replace : function ( blockContent , target , attbs ) {
69- if ( attbs ) {
70- return '<script src="' + target + '" ' + attbs + '></script>' ;
69+ replace : function ( blockContent , target , attrs ) {
70+ if ( attrs ) {
71+ return '<script src="' + target + '" ' + attrs + '></script>' ;
7172 }
7273 return '<script src="' + target + '"></script>' ;
7374 }
@@ -89,15 +90,20 @@ module.exports = function (gulp, $, options) {
8990 . pipe ( ( ) => {
9091 const vendorRegexp = new RegExp ( paths . vendors ) ;
9192 return $ . if ( vendorRegexp , $ . header ( options . banners . vendors , { pkg : options . pkg } ) ) ;
92- } ) ;
93+ } )
94+ . pipe ( ( ) => assetsFilter )
95+ . pipe ( gulp . dest , paths . dist . root )
96+ . pipe ( ( ) => assetsFilter . restore ) ;
9397
9498 } else {
95- userRefPipe = $ . util . noop ;
99+ useRef = $ . util . noop ;
96100 }
97101
98102 gulp . task ( 'views' , ( ) => {
99103
100104 const data = { } ;
105+ const htmlFilter = $ . filter ( '**/' + options . viewmatch , { restore : true } ) ;
106+
101107
102108 glob . sync ( '{,*/}*.json' , { cwd : fixturesPath } ) . forEach ( ( filename ) => {
103109 const id = _ . camelCase ( filename . toLowerCase ( ) . replace ( '.json' , '' ) ) ;
@@ -109,11 +115,13 @@ module.exports = function (gulp, $, options) {
109115 errorHandler : $ . notify . onError ( 'Error: <%= error.message %>' )
110116 } ) )
111117 . pipe ( map ( ( code ) => env . renderString ( code , Object . assign ( { } , baseData , data || { } ) ) ) )
112- . pipe ( userRefPipe ( ) )
118+ . pipe ( useRef ( ) )
113119 . pipe ( $ . rename ( ( filepath ) => {
114120 filepath . basename = filepath . basename . replace ( '.nunj' , '' ) ; //eslint-disable-line no-param-reassign
115121 } ) )
122+ . pipe ( htmlFilter )
116123 . pipe ( gulp . dest ( paths . dist . views ) )
124+ . pipe ( htmlFilter . restore )
117125 . pipe ( $ . if ( options . production , $ . rev . manifest ( path . join ( paths . dist . root , paths . dist . revmap ) , { merge : true } ) ) )
118126 . pipe ( $ . if ( options . production , gulp . dest ( '.' ) ) )
119127 . pipe ( $ . if ( options . isWatching , $ . notify ( { message : 'Views rendered' , onLast : true } ) ) ) ;
0 commit comments