Add livereload support and proxy to API.
This commit is contained in:
parent
43e4021e2c
commit
9f3b46ade1
@ -55,6 +55,7 @@ module.exports = function(grunt) {
|
||||
grunt.registerTask('serve', [
|
||||
'dev',
|
||||
'bgShell:runserver',
|
||||
'connect:livereload',
|
||||
'watch'
|
||||
]);
|
||||
|
||||
|
32
grunt-config/connect.js
Normal file
32
grunt-config/connect.js
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
@ -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']
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user