@@ -5,6 +5,7 @@ var gulp = require('gulp'),
55 del = require ( 'del' ) ,
66 minimist = require ( 'minimist' ) ,
77 wiredep = require ( 'wiredep' ) ,
8+ fsPath = require ( 'path' ) ,
89 plugins = require ( 'gulp-load-plugins' ) ( ) ,
910 bs = require ( 'browser-sync' ) . create ( ) ,
1011 config = require ( './config.json' ) ,
@@ -29,27 +30,26 @@ var args = minimist(process.argv.slice(2), knownOptions);
2930
3031var processWinPath = function ( file ) {
3132 // Fix for bug with paths on Windows
32- var path = require ( 'path' ) ;
3333 if ( process . platform === 'win32' ) {
34- file . path = path . relative ( '.' , file . path ) ;
34+ file . path = fsPath . relative ( '.' , file . path ) ;
3535 file . path = file . path . replace ( / \\ / g, '/' ) ;
3636 }
3737} ;
3838
3939// Compile SASS
4040gulp . task ( 'styles:sass' , function ( ) {
4141 var files = [
42- config . app + '/+(sass|app|common)/**/*.scss' ,
42+ config . paths . sass ,
4343 '!' + config . app + '/sass/includes/*.scss' ,
44- '!' + config . app + '/+( app|common) /**/_*.scss'
44+ '!' + config . app + '/app/**/_*.scss'
4545 ] ;
4646
4747 return gulp . src ( files , { read : false } )
4848 . on ( 'data' , processWinPath )
4949 . pipe ( plugins . plumber ( ) )
5050 . pipe ( plugins . order ( [
5151 config . app + '/sass/*.scss' ,
52- config . app + '/+( app|common) /*/*.scss'
52+ config . app + '/app/*/*.scss'
5353 ] , { base : '.' } ) )
5454 . pipe ( plugins . intercept ( function ( file ) {
5555 file . contents = new Buffer ( '@import \'' + file . path + '\';' ) ;
@@ -117,14 +117,13 @@ gulp.task('wiredep', function () {
117117// Cache AngularJS templates
118118var fnCacheTpls = function ( path ) {
119119 return gulp . src ( path )
120- . pipe ( plugins . minifyHtml ( {
121- empty : true ,
122- spare : true ,
123- quotes : true
124- } ) )
120+ . pipe ( plugins . htmlmin ( { collapseWhitespace : true } ) )
125121 . pipe ( plugins . angularTemplatecache ( {
126- module : 'app.templates' ,
127- standalone : true
122+ root : 'app' ,
123+ standalone : true ,
124+ transformUrl : function ( url ) {
125+ return url . replace ( fsPath . dirname ( url ) , '.' ) ;
126+ }
128127 } ) )
129128 . pipe ( plugins . concat ( config . templateFile ) )
130129 . pipe ( gulp . dest ( config . build + '/assets' ) )
@@ -158,21 +157,17 @@ gulp.task('scripts:lint', function () {
158157
159158var fnScripts = function ( ) {
160159 var files = [
161- config . app + '/+(app|common)/**/*.module.js' ,
162- config . app + '/+(app|common)/**/*.js' ,
160+ '!' + config . paths . tests ,
161+ config . app + '/app/**/*.module.js' ,
162+ config . app + '/app/**/*.js' ,
163163 '!' + config . paths . tests
164164 ] ;
165165
166166 return gulp . src ( files , { base : config . app } )
167167 . pipe ( plugins . plumber ( ) )
168168 . pipe ( plugins . sourcemaps . init ( ) )
169- . pipe ( plugins . concatUtil ( 'app.js' , {
170- process : function ( src ) {
171- return ( src . trim ( ) + '\n' ) . replace ( / ( ^ | \n ) [ \t ] * ( ' u s e s t r i c t ' | " u s e s t r i c t " ) ; ? \s * / g, '$1' ) ;
172- }
173- } ) )
174- . pipe ( plugins . concatUtil . header ( '(function (window, document, undefined) {\n\'use strict\';\n' ) )
175- . pipe ( plugins . concatUtil . footer ( '\n}) (window, document);\n' ) )
169+ . pipe ( plugins . ngAnnotate ( ) )
170+ . pipe ( plugins . concat ( 'app.js' ) )
176171 . pipe ( plugins . sourcemaps . write ( { sourceRoot : '/' + config . app } ) )
177172 . pipe ( plugins . size ( { showFiles : true , title : '»»»' } ) )
178173 . pipe ( gulp . dest ( config . build + '/assets' ) )
@@ -234,11 +229,7 @@ gulp.task('html:inject', ['styles:sass', 'scripts', 'wiredep'], function () {
234229gulp . task ( 'html' , [ 'optimize' ] , function ( ) {
235230 return gulp . src ( config . dist + '/index.html' )
236231 . pipe ( plugins . plumber ( ) )
237- . pipe ( plugins . minifyHtml ( {
238- empty : true ,
239- spare : true ,
240- quotes : true
241- } ) )
232+ . pipe ( plugins . htmlmin ( ) )
242233 . pipe ( gulp . dest ( config . dist ) ) ;
243234} ) ;
244235
@@ -269,9 +260,8 @@ gulp.task('optimize', optimizeTasks, function () {
269260 . pipe ( plugins . size ( { showFiles : true , title : '»»»' } ) )
270261 . pipe ( __filterCSS . restore )
271262 . pipe ( __filterJS )
272- . pipe ( plugins . ngAnnotate ( ) )
263+ // .pipe(plugins.ngAnnotate())
273264 . pipe ( plugins . uglify ( {
274- mangle : false ,
275265 compress : {
276266 drop_console : true
277267 }
@@ -364,7 +354,7 @@ gulp.task('watch', function () {
364354 } ) ;
365355
366356 // watch AngularJS templates to cache
367- gulp . watch ( config . app + '/+(app|common)/**/*.tpl.html' , [ 'scripts:cacheTpls' ] ) ;
357+ gulp . watch ( config . paths . templates , [ 'scripts:cacheTpls' ] ) ;
368358
369359 // watch for SASS changes
370360 gulp . watch ( config . paths . sass , [ 'styles:sass' ] ) ;
0 commit comments