[TASK] Replace grunt-connect with browser-sync

- Better for device testing
- Inject Scss
- Split watcher for faster reload
- Watch index.html
This commit is contained in:
Xaver Maierhofer 2016-05-29 16:38:57 +02:00
parent cdecdd9ee7
commit 575e784a5f
3 changed files with 29 additions and 26 deletions

View File

@ -5,7 +5,6 @@ module.exports = function (grunt) {
grunt.registerTask("default", ["bower-install-simple", "lint", "copy", "sass", "postcss", "requirejs:default", "inline"]); grunt.registerTask("default", ["bower-install-simple", "lint", "copy", "sass", "postcss", "requirejs:default", "inline"]);
grunt.registerTask("lint", ["sasslint", "eslint"]); grunt.registerTask("lint", ["sasslint", "eslint"]);
grunt.registerTask("dev", ["bower-install-simple", "lint", "copy", "sass", "requirejs:dev"]); grunt.registerTask("serve", ["bower-install-simple", "lint", "copy", "sass", "requirejs:dev", "browserSync", "watch"]);
grunt.registerTask("serve", ["dev", "connect:server", "watch"]);
}; };

View File

@ -17,12 +17,11 @@
"eslint-config-defaults": "^9.0.0", "eslint-config-defaults": "^9.0.0",
"grunt": "^1.0.1", "grunt": "^1.0.1",
"grunt-bower-install-simple": "^1.2.3", "grunt-bower-install-simple": "^1.2.3",
"grunt-browser-sync": "^2.2.0",
"grunt-check-dependencies": "^0.12.0", "grunt-check-dependencies": "^0.12.0",
"grunt-contrib-clean": "^1.0.0", "grunt-contrib-clean": "^1.0.0",
"grunt-contrib-connect": "^1.0.2",
"grunt-contrib-copy": "^1.0.0", "grunt-contrib-copy": "^1.0.0",
"grunt-contrib-requirejs": "^1.0.0", "grunt-contrib-requirejs": "^1.0.0",
"grunt-contrib-uglify": "^1.0.1",
"grunt-contrib-watch": "^1.0.0", "grunt-contrib-watch": "^1.0.0",
"grunt-eslint": "^18.1.0", "grunt-eslint": "^18.1.0",
"grunt-inline": "^0.3.6", "grunt-inline": "^0.3.6",

View File

@ -2,37 +2,42 @@ module.exports = function (grunt) {
"use strict"; "use strict";
grunt.config.merge({ grunt.config.merge({
connect: { "browserSync": {
dev: {
bsFiles: {
src: [
'build/*.css',
'build/*.js',
'build/*.html'
]
},
options: {
open: 'local',
watchTask: true,
injectChanges: true,
server: { server: {
options: { baseDir: "build",
base: {
path: "build",
options: {
index: "index.html" index: "index.html"
} }
},
livereload: true
} }
} }
}, },
watch: { watch: {
sources: { html: {
options: { files: ["html/index.html"],
livereload: true tasks: ["copy"]
}, },
files: ["*.css", "app.js", "lib/**/*.js", "*.html", "scss/**/*.scss"], sass: {
tasks: ["dev"] files: ["scss/**/*.scss"],
tasks: ["sasslint", "sass"]
}, },
config: { js: {
options: { files: ["app.js", "lib/**/*.js"],
reload: true tasks: ["eslint", "requirejs:dev"]
},
files: ["Gruntfile.js", "tasks/*.js"],
tasks: []
} }
} }
}); });
grunt.loadNpmTasks("grunt-contrib-connect"); grunt.loadNpmTasks("grunt-browser-sync");
grunt.loadNpmTasks("grunt-contrib-watch"); grunt.loadNpmTasks("grunt-contrib-watch");
}; };