changeset 23:c1ef0be0ae3d

Improve build chain In order to improve the build, there is the need to include external asset during build time. The variable `VUE_APP_VENDOR_IMG_PATH` defines the source folder of the vendor images. The destination folder is /web/img/. To improve readability comments to .env.sample variables were added.
author Thomas Junk <thomas.junk@intevation.de>
date Thu, 21 Jun 2018 13:39:01 +0200
parents d53de4169d11
children 10ebbf197523
files client/.env.sample client/package.json client/vue.config.js
diffstat 3 files changed, 21 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/client/.env.sample	Thu Jun 21 12:53:16 2018 +0200
+++ b/client/.env.sample	Thu Jun 21 13:39:01 2018 +0200
@@ -1,3 +1,11 @@
+#Name of the application, e.g. displayed at login time
 VUE_APP_TITLE=Waterway Monitoring system
+
+#Backend URL
 VUE_APP_API_URL=/api/
+
+#URL of secondary logo
 VUE_APP_SECONDARY_LOGO_URL=
+
+#Path of vendored images is copied during a webpack build
+VUE_APP_VENDOR_IMG_PATH=
--- a/client/package.json	Thu Jun 21 12:53:16 2018 +0200
+++ b/client/package.json	Thu Jun 21 13:39:01 2018 +0200
@@ -27,6 +27,7 @@
     "babel-core": "7.0.0-bridge.0",
     "babel-jest": "^23.0.1",
     "concurrently": "^3.5.1",
+    "copy-webpack-plugin": "^4.5.1",
     "node-sass": "^4.9.0",
     "pretty-quick": "^1.6.0",
     "sass-loader": "^7.0.1",
--- a/client/vue.config.js	Thu Jun 21 12:53:16 2018 +0200
+++ b/client/vue.config.js	Thu Jun 21 13:39:01 2018 +0200
@@ -1,12 +1,23 @@
+var CopyWebpackPlugin = require("copy-webpack-plugin");
+
 module.exports = {
   outputDir: "../web",
+  chainWebpack: config => {
+    let vendorImgPath = process.env.VUE_APP_VENDOR_IMG_PATH;
+    if (!vendorImgPath) return;
+    config
+      .plugin("CopyWebpackPlugin")
+      .use(CopyWebpackPlugin, [[{ from: vendorImgPath, to: "img" }]], {
+        copyUnmodified: true
+      });
+  },
   devServer: {
     proxy: {
       "/api/*": {
         target: "http://localhost:8000",
         secure: false
       },
-      "/assets/*": {
+      "/img/*": {
         target: "http://localhost:5000",
         secure: false
       }