Skip to content
This repository has been archived by the owner on Mar 26, 2018. It is now read-only.

feat(Gruntfile): switch to BrowserSync #1029

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 40 additions & 47 deletions templates/common/root/_Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -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) { %>
Expand All @@ -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'
}
}
}
}
},
Expand Down Expand Up @@ -489,17 +482,17 @@ 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([
'clean:server',
'wiredep',
'concurrent:server',
'autoprefixer:server',
'connect:livereload',
'browserSync:livereload',
'watch'
]);
});
Expand All @@ -514,7 +507,7 @@ module.exports = function (grunt) {
'wiredep',
'concurrent:test',
'autoprefixer',
'connect:test',
'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 @@ -11,14 +11,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": "^0.9.2",
"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",
Expand Down