You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2021/04/08 19:07:41 UTC

[airavata-django-portal] branch develop updated: Common UI components library, for use in custom apps

This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git


The following commit(s) were added to refs/heads/develop by this push:
     new 6bcdebc  Common UI components library, for use in custom apps
     new 4e39edd  Merge branch 'common-ui-components-lib' into develop
6bcdebc is described below

commit 6bcdebc3cfd492802b6a95b33ee2cbcdfaa0f46d
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Thu Apr 8 15:06:47 2021 -0400

    Common UI components library, for use in custom apps
---
 django_airavata/static/common/js/components.js |  3 +++
 django_airavata/static/common/package.json     |  6 ++++--
 django_airavata/static/common/vue.config.js    | 25 ++++++++++++++++++-------
 3 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/django_airavata/static/common/js/components.js b/django_airavata/static/common/js/components.js
new file mode 100644
index 0000000..01855b1
--- /dev/null
+++ b/django_airavata/static/common/js/components.js
@@ -0,0 +1,3 @@
+import NotificationsDisplay from "./components/NotificationsDisplay.vue";
+
+export { NotificationsDisplay };
diff --git a/django_airavata/static/common/package.json b/django_airavata/static/common/package.json
index 5213499..c2d1bbb 100644
--- a/django_airavata/static/common/package.json
+++ b/django_airavata/static/common/package.json
@@ -8,10 +8,12 @@
   "module": "./js/index.js",
   "scripts": {
     "watch": "vue-cli-service build --watch --mode production",
-    "build": "vue-cli-service build",
+    "build": "npm run build-app && npm run build-lib",
+    "build-app": "vue-cli-service build",
+    "build-lib": "LIBRARY_MODE=true vue-cli-service build --target lib --name CommonUI --no-clean ./js/components.js",
     "lint": "vue-cli-service lint ./js/",
     "lint:visualstudio": "vue-cli-service lint --format visualstudio ./js/",
-    "format": "prettier --write ."
+    "format": "prettier --check --write ."
   },
   "dependencies": {
     "@fortawesome/fontawesome-free": "^5.6.3",
diff --git a/django_airavata/static/common/vue.config.js b/django_airavata/static/common/vue.config.js
index 55188ec..aa4379a 100644
--- a/django_airavata/static/common/vue.config.js
+++ b/django_airavata/static/common/vue.config.js
@@ -7,12 +7,23 @@ module.exports = {
     cms: "./js/cms.js",
     notices: "./js/notices.js",
   },
-  configureWebpack: {
-    plugins: [
-      new BundleTracker({
-        filename: "webpack-stats.json",
-        path: "./dist/",
-      }),
-    ],
+  configureWebpack: (config) => {
+    if (process.env.LIBRARY_MODE === "true") {
+      // Externalize the django-airavata-api library, will be available to
+      // custom apps as global AiravataAPI object
+      config.externals = config.externals || {};
+      config.externals["django-airavata-api"] = {
+        commonjs: "django-airavata-api",
+        commonjs2: "django-airavata-api",
+        root: "AiravataAPI",
+      };
+    } else {
+      config.plugins.push(
+        new BundleTracker({
+          filename: "webpack-stats.json",
+          path: "./dist/",
+        })
+      );
+    }
   },
 };