You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by ni...@apache.org on 2020/03/18 10:19:28 UTC
[kylin] branch master updated: add devserver task
This is an automated email from the ASF dual-hosted git repository.
nic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kylin.git
The following commit(s) were added to refs/heads/master by this push:
new 5e8fe00 add devserver task
5e8fe00 is described below
commit 5e8fe00ccd0f7a38d5e9910998614e5a847f30f1
Author: Congling Xia <xi...@xiaomi.com>
AuthorDate: Wed Mar 11 12:01:45 2020 +0800
add devserver task
---
webapp/Gruntfile.js | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++
webapp/package.json | 3 +++
2 files changed, 71 insertions(+)
diff --git a/webapp/Gruntfile.js b/webapp/Gruntfile.js
index a977a73..5e394c3 100644
--- a/webapp/Gruntfile.js
+++ b/webapp/Gruntfile.js
@@ -245,6 +245,60 @@ module.exports = function (grunt) {
e2e: {
configFile: 'karma.e2e.conf.js'
}
+ },
+ watch: {
+ appchange: {
+ options: {
+ livereload: true,
+ },
+ files: [
+ "app/css/*.*",
+ "app/fonts/*.*",
+ "app/image/*.*",
+ "app/js/*.*",
+ "app/less/*.*",
+ "app/partials/**/*.*",
+ "app/*.*"
+ ],
+ tasks: ['dev']
+ }
+ },
+ connect: {
+ options: {
+ port: 7071, // custom port
+ base: './dist', // current directory for 'index.html' is root
+ livereload: true,
+ },
+ rules: [ // rewrite rules for static resources
+ {from: '^/kylin/routes.json$', to: '/routes.json'},
+ {from: '^/kylin/((css|fonts|image|js)/.*)$', to: '/$1'},
+ {from: '^/kylin/(?!api/).*$', to: '/'},
+ ],
+ devserver: {
+ options: {
+ middleware: function (connect, options) {
+ var rewriteRulesSnippet = require('grunt-connect-rewrite/lib/utils').rewriteRequest;
+ var proxySnippet = require('grunt-connect-proxy/lib/utils').proxyRequest;
+ var middlewares = [rewriteRulesSnippet, proxySnippet];
+ if (!Array.isArray(options.base)) {
+ options.base = [options.base];
+ }
+ var directory = options.directory || options.base[options.base.length - 1];
+ options.base.forEach(function (base) {
+ middlewares.push(connect.static(base));
+ });
+ middlewares.push(connect.directory(directory));
+ return middlewares;
+ }
+ },
+ proxies: [
+ {
+ context: '/kylin/api',
+ host: '127.0.0.1',
+ port: '7070'
+ }
+ ]
+ }
}
});
@@ -300,4 +354,18 @@ module.exports = function (grunt) {
'manifest',
'changelog'
]);
+
+ grunt.loadNpmTasks('grunt-contrib-watch');
+ grunt.loadNpmTasks('grunt-connect-proxy');
+ grunt.loadNpmTasks('grunt-connect-rewrite');
+
+ grunt.registerTask('devserver', function (target) {
+ grunt.task.run([
+ 'dev',
+ 'configureRewriteRules',
+ 'configureProxies:devserver',
+ 'connect:devserver',
+ 'watch:appchange',
+ ]);
+ });
};
diff --git a/webapp/package.json b/webapp/package.json
index b11a162..9392f72 100644
--- a/webapp/package.json
+++ b/webapp/package.json
@@ -10,7 +10,10 @@
"devDependencies": {
"grunt": "~0.4.x",
"grunt-cli": "~0.1.13",
+ "grunt-connect-proxy": "^0.2.0",
+ "grunt-connect-rewrite": "^0.2.2",
"grunt-contrib": "~0.7.0",
+ "grunt-contrib-watch": "^1.1.0",
"grunt-html2js": "~0.1.3",
"grunt-bump": "0.0.6",
"grunt-htmlrefs": "~0.4.1",