forked from yeoman/generator-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Gruntfile): switch to BrowserSync yeoman#1029
- Loading branch information
Showing
3 changed files
with
207 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters