From 575e784a5fbca5410a6c2151d706f8cffad964ff Mon Sep 17 00:00:00 2001 From: Xaver Maierhofer Date: Sun, 29 May 2016 16:38:57 +0200 Subject: [PATCH] [TASK] Replace grunt-connect with browser-sync - Better for device testing - Inject Scss - Split watcher for faster reload - Watch index.html --- Gruntfile.js | 3 +-- package.json | 3 +-- tasks/development.js | 49 ++++++++++++++++++++++++-------------------- 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index c0c6fab..fb6d439 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -5,7 +5,6 @@ module.exports = function (grunt) { grunt.registerTask("default", ["bower-install-simple", "lint", "copy", "sass", "postcss", "requirejs:default", "inline"]); grunt.registerTask("lint", ["sasslint", "eslint"]); - grunt.registerTask("dev", ["bower-install-simple", "lint", "copy", "sass", "requirejs:dev"]); - grunt.registerTask("serve", ["dev", "connect:server", "watch"]); + grunt.registerTask("serve", ["bower-install-simple", "lint", "copy", "sass", "requirejs:dev", "browserSync", "watch"]); }; diff --git a/package.json b/package.json index af920fd..6d52ef5 100644 --- a/package.json +++ b/package.json @@ -17,12 +17,11 @@ "eslint-config-defaults": "^9.0.0", "grunt": "^1.0.1", "grunt-bower-install-simple": "^1.2.3", + "grunt-browser-sync": "^2.2.0", "grunt-check-dependencies": "^0.12.0", "grunt-contrib-clean": "^1.0.0", - "grunt-contrib-connect": "^1.0.2", "grunt-contrib-copy": "^1.0.0", "grunt-contrib-requirejs": "^1.0.0", - "grunt-contrib-uglify": "^1.0.1", "grunt-contrib-watch": "^1.0.0", "grunt-eslint": "^18.1.0", "grunt-inline": "^0.3.6", diff --git a/tasks/development.js b/tasks/development.js index 938cd87..6192b91 100644 --- a/tasks/development.js +++ b/tasks/development.js @@ -2,37 +2,42 @@ module.exports = function (grunt) { "use strict"; grunt.config.merge({ - connect: { - server: { + "browserSync": { + dev: { + bsFiles: { + src: [ + 'build/*.css', + 'build/*.js', + 'build/*.html' + ] + }, options: { - base: { - path: "build", - options: { - index: "index.html" - } - }, - livereload: true + open: 'local', + watchTask: true, + injectChanges: true, + server: { + baseDir: "build", + index: "index.html" + } } } }, watch: { - sources: { - options: { - livereload: true - }, - files: ["*.css", "app.js", "lib/**/*.js", "*.html", "scss/**/*.scss"], - tasks: ["dev"] + html: { + files: ["html/index.html"], + tasks: ["copy"] }, - config: { - options: { - reload: true - }, - files: ["Gruntfile.js", "tasks/*.js"], - tasks: [] + sass: { + files: ["scss/**/*.scss"], + tasks: ["sasslint", "sass"] + }, + js: { + files: ["app.js", "lib/**/*.js"], + tasks: ["eslint", "requirejs:dev"] } } }); - grunt.loadNpmTasks("grunt-contrib-connect"); + grunt.loadNpmTasks("grunt-browser-sync"); grunt.loadNpmTasks("grunt-contrib-watch"); };