Skip to content

Commit

Permalink
feat(Gruntfile): switch to BrowserSync yeoman#1029
Browse files Browse the repository at this point in the history
  • Loading branch information
padouk committed Nov 21, 2015
1 parent b0910b4 commit 8683802
Show file tree
Hide file tree
Showing 3 changed files with 207 additions and 48 deletions.
164 changes: 164 additions & 0 deletions 1029.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
diff --git a/templates/common/root/_Gruntfile.js b/templates/common/root/_Gruntfile.js
index a715598..f966742 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 6a62991..f2cce83 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",
89 changes: 42 additions & 47 deletions templates/common/root/_Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ module.exports = function (grunt) {
},<% } else { %>
js: {
files: ['<%%= yeoman.app %>/scripts/{,*/}*.js'],
tasks: ['newer:jshint:all', 'newer:jscs:all'],
options: {
livereload: '<%%= connect.options.livereload %>'
}
tasks: ['newer:jshint:all', 'newer:jscs:all']
},
jsTest: {
files: ['test/spec/{,*/}*.js'],
Expand All @@ -76,9 +73,6 @@ module.exports = function (grunt) {
files: ['Gruntfile.js']
},
livereload: {
options: {
livereload: '<%%= connect.options.livereload %>'
},
files: [
'<%%= yeoman.app %>/{,*/}*.html',
'.tmp/styles/{,*/}*.css',<% if (coffee || typescript) { %>
Expand All @@ -89,52 +83,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'
}
}
}
}
},
Expand Down Expand Up @@ -571,9 +564,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([
Expand All @@ -582,7 +575,8 @@ module.exports = function (grunt) {
'tsd:refresh',<% } %>
'concurrent:server',
'postcss:server',
'connect:livereload',
'autoprefixer:server',
'browserSync:livereload',
'watch'
]);
});
Expand All @@ -598,7 +592,8 @@ module.exports = function (grunt) {
'tsd:refresh',<% } %>
'concurrent:test',
'postcss',
'connect:test',
'autoprefixer',
'browserSync:test',
'karma'
]);

Expand Down
2 changes: 1 addition & 1 deletion templates/common/root/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
"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",
"grunt-contrib-imagemin": "^1.0.0",
"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",<% if (!coffee) { %>
"grunt-jscs": "^1.8.0",<% } %>
Expand Down

0 comments on commit 8683802

Please sign in to comment.