gruntjs - Setting up grunt to launch & live reload browser (with minimal plugins) -
i'm setting web project , want use grunt automation , workflow. have sass, jshint, jsdocs, minifiers playing nice having no end of trouble launch & reload of browser grunt shell.
i have 2 conditions i'd meet in doing this:
no browser plugins. (i want work straight out of repo; "npm install", "grunt") keep npm modules minimum. (ideally grunt-contrib-watch & grunt-contrib-connect)
this config 2:
connect: { options: { base: 'app/', port: '8888', livereload: true } }, watch: { all: { files: [ 'gruntfile.js', 'app/index.html', 'app/partials/*.html', 'app/styles/sass/*.scss', 'app/scripts/*.js' ], tasks: ['default'], options: { livereload: true } } }
in testing have tried:
connect: { options: { base: "app/", port: 8888, open: { target: 'app/index.html' } } }
watch tells me when files change, running default task (or of sub-tasks it's made from) not launch browser/page , there seems no reload.
i had success grunt-open, i'm lead believe should achievable grunt-contrib-watch after version 0.6.0 ?
----- additional i'm unsure if grunt-contrib-connect being run...
grunt.registertask('serve', ['sass', 'connect', 'watch']); grunt.registertask('default', ['jshint', 'serve']);
results in following, don't see timings connect, i'm guessing task not measured because runs in parallel, happening?
execution time loading tasks 12ms ▇▇▇▇▇ 10% jshint:src 78ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 62% sass:all 11ms ▇▇▇▇▇ 9% watch 24ms ▇▇▇▇▇▇▇▇▇ 19% total 126ms
well, not sure if it, update see connect
wouldn't ever run because have no target specified:
connect: { server: { // try adding block options: { base: 'app/', port: '8888', livereload: true } } },
otherwise, looks correct, explicitly state port want live reload:
watch: { all: { files: [ // ... ], tasks: ['default'], options: { livereload: 8888 // changed... } } }
Comments
Post a Comment