Skip to content
This repository has been archived by the owner on May 25, 2019. It is now read-only.

Commit

Permalink
replace contrib-connect with browser-sync
Browse files Browse the repository at this point in the history
  • Loading branch information
gaboesquivel committed Apr 3, 2015
1 parent a4c5b20 commit e014868
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 46 deletions.
75 changes: 30 additions & 45 deletions app/templates/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ module.exports = function (grunt) {
js: {
files: ['<%%= config.app %>/scripts/{,*/}*.js'],
tasks: ['jshint'],
options: {
livereload: '<%%= connect.options.livereload %>'
}
},
jstest: {
files: ['test/spec/{,*/}*.js'],
Expand All @@ -65,58 +62,48 @@ module.exports = function (grunt) {
styles: {
files: ['<%%= config.app %>/styles/{,*/}*.css'],
tasks: ['newer:copy:styles', 'autoprefixer']
},
livereload: {
options: {
livereload: '<%%= connect.options.livereload %>'
},
files: [
'<%%= config.app %>/{,*/}*.html',
'.tmp/styles/{,*/}*.css',<% if (coffee) { %>
'.tmp/scripts/{,*/}*.js',<% } %>
'<%%= config.app %>/images/{,*/}*'
]
}
},

// The actual grunt server settings
connect: {
browserSync: {
options: {
port: 9000,
open: true,
livereload: 35729,
// Change this to '0.0.0.0' to access the server from outside
hostname: 'localhost'
notify: false,
background: true
},
livereload: {
options: {
middleware: function(connect) {
return [
connect.static('.tmp'),
connect().use('/bower_components', connect.static('./bower_components')),
connect.static(config.app)
];
files: [
'<%%= config.app %>/{,*/}*.html',
'.tmp/styles/{,*/}*.css',
'<%%= config.app %>/images/{,*/}*',
'<%%= config.app %>/scripts/{,*/}*.js'
],
server: {
baseDir: ['.tmp', config.app],
routes: {
'/bower_components': './bower_components'
}
}
}
},
test: {
options: {
open: false,
port: 9001,
middleware: function(connect) {
return [
connect.static('.tmp'),
connect.static('test'),
connect().use('/bower_components', connect.static('./bower_components')),
connect.static(config.app)
];
open: false,
logLevel: 'silent',
host: 'localhost',
server: {
baseDir: ['.tmp', './test', config.app],
routes: {
'/bower_components': './bower_components'
}
}
}
},
dist: {
options: {
base: '<%%= config.dist %>',
livereload: false
background: false,
server: '<%%= config.dist %>'
}
}
},
Expand Down Expand Up @@ -155,7 +142,7 @@ module.exports = function (grunt) {
all: {
options: {
run: true,
urls: ['http://<%%= connect.test.options.hostname %>:<%%= connect.test.options.port %>/index.html']
urls: ['http://<%%= browserSync.test.options.host %>:<%%= browserSync.test.options.port %>/index.html']
}
}
},<% } else if (testFramework === 'jasmine') { %>
Expand Down Expand Up @@ -438,20 +425,18 @@ module.exports = function (grunt) {
});


grunt.registerTask('serve', 'start the server and preview your app, --allow-remote for remote access', function (target) {
if (grunt.option('allow-remote')) {
grunt.config.set('connect.options.hostname', '0.0.0.0');
}
grunt.registerTask('serve', 'start the server and preview your app', 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',
'connect:livereload',
'browserSync:livereload',
'watch'
]);
});
Expand All @@ -471,7 +456,7 @@ module.exports = function (grunt) {
}

grunt.task.run([
'connect:test',<% if (testFramework === 'mocha') { %>
'browserSync:test',<% if (testFramework === 'mocha') { %>
'mocha'<% } else if (testFramework === 'jasmine') { %>
'jasmine'<% } %>
]);
Expand Down
2 changes: 1 addition & 1 deletion app/templates/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"grunt": "^0.4.5",
"grunt-autoprefixer": "^1.0.0",
"grunt-concurrent": "^0.5.0",
"grunt-browser-sync": "^2.1.1",
"grunt-contrib-clean": "^0.6.0",<% if (coffee) { %>
"grunt-contrib-coffee": "^0.11.0",<% } %>
"grunt-contrib-concat": "^0.5.0",
"grunt-contrib-connect": "^0.8.0",
"grunt-contrib-copy": "^0.5.0",
"grunt-contrib-cssmin": "^0.10.0",
"grunt-contrib-htmlmin": "^0.3.0",
Expand Down

0 comments on commit e014868

Please sign in to comment.