From 5c8bbb905ecc1b45bb85ebc3c9e932cecfe40411 Mon Sep 17 00:00:00 2001 From: Felipe Marcos Date: Sun, 8 Mar 2015 15:32:40 -0300 Subject: [PATCH 1/2] feat(Gruntfile): switch to BrowserSync --- templates/common/root/_Gruntfile.js | 87 +++++++++++++---------------- templates/common/root/_package.json | 2 +- 2 files changed, 41 insertions(+), 48 deletions(-) diff --git a/templates/common/root/_Gruntfile.js b/templates/common/root/_Gruntfile.js index a715598fe..4d07d3eaf 100644 --- a/templates/common/root/_Gruntfile.js +++ b/templates/common/root/_Gruntfile.js @@ -43,10 +43,7 @@ module.exports = function (grunt) { },<% } else { %> js: { files: ['<%%= yeoman.app %>/scripts/{,*/}*.js'], - tasks: ['newer:jshint:all'], - options: { - livereload: '<%%= connect.options.livereload %>' - } + tasks: ['newer:jshint:all'] }, jsTest: { files: ['test/spec/{,*/}*.js'], @@ -64,9 +61,6 @@ module.exports = function (grunt) { files: ['Gruntfile.js'] }, livereload: { - options: { - livereload: '<%%= connect.options.livereload %>' - }, files: [ '<%%= yeoman.app %>/{,*/}*.html', '.tmp/styles/{,*/}*.css',<% if (coffee) { %> @@ -77,52 +71,51 @@ module.exports = function (grunt) { }, // The actual grunt server settings - connect: { - options: { - port: 9000, - // Change this to '0.0.0.0' to access the server from outside. - hostname: 'localhost', - livereload: 35729 - }, + browserSync: { livereload: { + bsFiles: { + src: [ + '<%%= yeoman.app %>/**/*.html', + '.tmp/styles/**/*.css', + '<%%= yeoman.app %>/scripts/**/*.js', + '<%%= yeoman.app %>/images/**/*.+(png/jpg/jpeg/gif/webp/svg)' + ] + }, options: { - open: true, - middleware: function (connect) { - return [ - connect.static('.tmp'), - connect().use( - '/bower_components', - connect.static('./bower_components') - ), - connect().use( - '/app/styles', - connect.static('./app/styles') - ), - connect.static(appConfig.app) - ]; + watchTask: true, + server: { + baseDir: [appConfig.app, '.tmp'], + routes: { + '/bower_components': 'bower_components' + } } } }, - test: { + dist: { + bsFiles: { + src: '<%= yeoman.dist %>/**/*.html' + }, options: { - port: 9001, - middleware: function (connect) { - return [ - connect.static('.tmp'), - connect.static('test'), - connect().use( - '/bower_components', - connect.static('./bower_components') - ), - connect.static(appConfig.app) - ]; + server: { + baseDir: appConfig.dist } } }, - dist: { + test: { + bsFiles: { + src: 'test/spec/**/*.js' + }, options: { - open: true, - base: '<%%= yeoman.dist %>' + watchTask: true, + port: 9001, + open: false, + logLevel: 'silent', + server: { + baseDir: ['test', '.tmp', appConfig.app], + routes: { + '/bower_components': 'bower_components' + } + } } } }, @@ -489,9 +482,9 @@ module.exports = function (grunt) { }); - grunt.registerTask('serve', 'Compile then start a connect web server', function (target) { + grunt.registerTask('serve', 'Compile then start a BrowserSync web server', function (target) { if (target === 'dist') { - return grunt.task.run(['build', 'connect:dist:keepalive']); + return grunt.task.run(['build', 'browserSync:dist']); } grunt.task.run([ @@ -499,7 +492,7 @@ module.exports = function (grunt) { 'wiredep', 'concurrent:server', 'autoprefixer:server', - 'connect:livereload', + 'browserSync:livereload', 'watch' ]); }); @@ -514,7 +507,7 @@ module.exports = function (grunt) { 'wiredep', 'concurrent:test', 'autoprefixer', - 'connect:test', + 'browserSync:test', 'karma' ]); diff --git a/templates/common/root/_package.json b/templates/common/root/_package.json index 6a6299145..f2cce839a 100644 --- a/templates/common/root/_package.json +++ b/templates/common/root/_package.json @@ -11,7 +11,6 @@ "grunt-contrib-coffee": "^0.12.0",<% } %><% if (compass) { %> "grunt-contrib-compass": "^1.0.0",<% } %> "grunt-contrib-concat": "^0.5.0", - "grunt-contrib-connect": "^0.9.0", "grunt-contrib-copy": "^0.7.0", "grunt-contrib-cssmin": "^0.12.0", "grunt-contrib-htmlmin": "^0.4.0", @@ -19,6 +18,7 @@ "grunt-contrib-jshint": "^0.11.0", "grunt-contrib-uglify": "^0.7.0", "grunt-contrib-watch": "^0.6.1", + "grunt-browser-sync": "^2.0.0", "grunt-filerev": "^2.1.2", "grunt-google-cdn": "^0.4.3", "grunt-newer": "^1.1.0", From 4cfb6493e635ed06bd5d2b4d5d0be376886ef41e Mon Sep 17 00:00:00 2001 From: Felipe Marcos Date: Wed, 11 Mar 2015 19:47:00 -0300 Subject: [PATCH 2/2] chore(Gruntfile): ensure consistency on BrowserSync settings --- templates/common/root/_Gruntfile.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/templates/common/root/_Gruntfile.js b/templates/common/root/_Gruntfile.js index 4d07d3eaf..f96674294 100644 --- a/templates/common/root/_Gruntfile.js +++ b/templates/common/root/_Gruntfile.js @@ -75,10 +75,10 @@ module.exports = function (grunt) { livereload: { bsFiles: { src: [ - '<%%= yeoman.app %>/**/*.html', - '.tmp/styles/**/*.css', - '<%%= yeoman.app %>/scripts/**/*.js', - '<%%= yeoman.app %>/images/**/*.+(png/jpg/jpeg/gif/webp/svg)' + '<%%= yeoman.app %>/{,*/}*.html', + '.tmp/styles/{,*/}*.css', + '<%%= yeoman.app %>/scripts/{,*/}*.js', + '<%%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}' ] }, options: { @@ -93,7 +93,7 @@ module.exports = function (grunt) { }, dist: { bsFiles: { - src: '<%= yeoman.dist %>/**/*.html' + src: '<%%= yeoman.dist %>/{,*/}*.html' }, options: { server: { @@ -103,7 +103,7 @@ module.exports = function (grunt) { }, test: { bsFiles: { - src: 'test/spec/**/*.js' + src: 'test/spec/{,*/}*.js' }, options: { watchTask: true,