diff --git a/Gruntfile.js b/Gruntfile.js index a5550d2..9d310ea 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -55,6 +55,7 @@ module.exports = function(grunt) { grunt.registerTask('serve', [ 'dev', 'bgShell:runserver', + 'connect:livereload', 'watch' ]); diff --git a/grunt-config/connect.js b/grunt-config/connect.js new file mode 100644 index 0000000..a6c3574 --- /dev/null +++ b/grunt-config/connect.js @@ -0,0 +1,32 @@ +'use strict'; + +module.exports = { + options: { + port: 5001, + hostname: 'localhost', + base: '<%= accountant.frontend.src %>', + apiUrl: 'http://localhost:5000/api/', + livereload: 1337, + }, + proxies: [{ + context: '/api', + host: '127.0.0.1', + port: 5000, + https: false + }], + livereload: { + options: { + //open: true, + middleware: function(connect, options, middlewares) { + var connectLogger = require('connect-logger'); + var connectProxy = require('connect-proxy-layer'); + var proxy = connectProxy(options.apiUrl); + + return [ + connectLogger(), + connect().use('/api', proxy), + ].concat(middlewares); + } + } + } +}; diff --git a/grunt-config/watch.js b/grunt-config/watch.js index 8f4cc90..3955edc 100644 --- a/grunt-config/watch.js +++ b/grunt-config/watch.js @@ -26,6 +26,16 @@ module.exports = { gruntfile: { files: ['Gruntfile.js', 'grunt-config/*.js'] }, + livereload: { + options: { + livereload: '<%= connect.options.livereload %>' + }, + files: [ + '<%= accountant.frontend.src %>/{,*/}*.html', + '<%= accountant.frontend.src %>/js/*.js', + '<%= accountant.frontend.src %>/css/*.css' + ] + }, requirements: { files: ['requirements.txt'], tasks: ['shell:pip_install'] diff --git a/package.json b/package.json index 4a8c6f5..2a9262a 100644 --- a/package.json +++ b/package.json @@ -4,10 +4,13 @@ "repository": "https://git.lahouze.org/xals/accountant", "license": "AGPL-1.0", "devDependencies": { + "connect-logger": "0.0.1", + "connect-proxy-layer": "^0.1.2", "grunt": "^0.4.5", "grunt-bg-shell": "^2.3.1", "grunt-contrib-clean": "^1.0.0", "grunt-contrib-concat": "^0.5.1", + "grunt-contrib-connect": "^0.11.2", "grunt-contrib-cssmin": "^0.14.0", "grunt-contrib-jshint": "^1.0.0", "grunt-contrib-uglify": "^0.11.1",