Add livereload support and proxy to API.

This commit is contained in:
Alexis Lahouze 2016-02-23 23:10:38 +01:00
parent 43e4021e2c
commit 9f3b46ade1
4 changed files with 46 additions and 0 deletions

View File

@ -55,6 +55,7 @@ module.exports = function(grunt) {
grunt.registerTask('serve', [ grunt.registerTask('serve', [
'dev', 'dev',
'bgShell:runserver', 'bgShell:runserver',
'connect:livereload',
'watch' 'watch'
]); ]);

32
grunt-config/connect.js Normal file
View File

@ -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);
}
}
}
};

View File

@ -26,6 +26,16 @@ module.exports = {
gruntfile: { gruntfile: {
files: ['Gruntfile.js', 'grunt-config/*.js'] 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: { requirements: {
files: ['requirements.txt'], files: ['requirements.txt'],
tasks: ['shell:pip_install'] tasks: ['shell:pip_install']

View File

@ -4,10 +4,13 @@
"repository": "https://git.lahouze.org/xals/accountant", "repository": "https://git.lahouze.org/xals/accountant",
"license": "AGPL-1.0", "license": "AGPL-1.0",
"devDependencies": { "devDependencies": {
"connect-logger": "0.0.1",
"connect-proxy-layer": "^0.1.2",
"grunt": "^0.4.5", "grunt": "^0.4.5",
"grunt-bg-shell": "^2.3.1", "grunt-bg-shell": "^2.3.1",
"grunt-contrib-clean": "^1.0.0", "grunt-contrib-clean": "^1.0.0",
"grunt-contrib-concat": "^0.5.1", "grunt-contrib-concat": "^0.5.1",
"grunt-contrib-connect": "^0.11.2",
"grunt-contrib-cssmin": "^0.14.0", "grunt-contrib-cssmin": "^0.14.0",
"grunt-contrib-jshint": "^1.0.0", "grunt-contrib-jshint": "^1.0.0",
"grunt-contrib-uglify": "^0.11.1", "grunt-contrib-uglify": "^0.11.1",