aboutsummaryrefslogtreecommitdiff
path: root/viewer/vue.config.js
diff options
context:
space:
mode:
authorpacien2020-09-25 16:01:49 +0200
committerpacien2020-09-25 16:01:49 +0200
commite93f7b1eb84c083d67567115284c0002a3a7d5fc (patch)
tree8d373e8f7f571485e1330928f43b090ed004c525 /viewer/vue.config.js
parent8e3ac8fe44bebb38e1882ca7f06b8100078ad88d (diff)
parentfd542f75a1d94ee5f804d0925823276b97f38581 (diff)
downloadldgallery-2.0.tar.gz
Merge branch 'develop' for release v2.0v2.0
Diffstat (limited to 'viewer/vue.config.js')
-rw-r--r--viewer/vue.config.js46
1 files changed, 32 insertions, 14 deletions
diff --git a/viewer/vue.config.js b/viewer/vue.config.js
index f481e4f..8649b6d 100644
--- a/viewer/vue.config.js
+++ b/viewer/vue.config.js
@@ -17,6 +17,33 @@
17-- along with this program. If not, see <https://www.gnu.org/licenses/>. 17-- along with this program. If not, see <https://www.gnu.org/licenses/>.
18*/ 18*/
19 19
20/*
21-- Create a file .env.development.local in the project to customize your DevServer
22-- VUE_APP_DEVSERVER_CONFIG_PATH=<http_url> will use the dev_proxyconfig
23-- VUE_APP_DEVSERVER_CONFIG_PATH=<fs_path> will use the dev_fsconfig
24*/
25const dev_ready = Boolean(process.env.VUE_APP_DEVSERVER_CONFIG_PATH);
26const dev_isproxy = dev_ready && Boolean(process.env.VUE_APP_DEVSERVER_CONFIG_PATH.match(/^https?:\/\//i));
27const dev_localpath = `^/${process.env.VUE_APP_DATA_URL}`;
28const dev_proxyconfig = {
29 [dev_localpath]: {
30 target: process.env.VUE_APP_DEVSERVER_CONFIG_PATH,
31 pathRewrite: { [dev_localpath]: "" },
32 },
33};
34const dev_fsconfig = (app, server, compiler) => {
35 app.get(`${dev_localpath}*`, (req, res) => {
36 const fs = require("fs");
37 const url = req.url.slice(process.env.VUE_APP_DATA_URL.length);
38 const paramIdx = url.indexOf("?");
39 const filepath = paramIdx < 0 ? url : url.substring(0, paramIdx);
40 const fullpath = `${process.env.VUE_APP_DEVSERVER_CONFIG_PATH}${decodeURIComponent(filepath)}`;
41 const file = fs.readFileSync(fullpath);
42 res.end(file);
43 });
44};
45// =================
46
20module.exports = { 47module.exports = {
21 publicPath: "./", 48 publicPath: "./",
22 pluginOptions: { 49 pluginOptions: {
@@ -27,26 +54,17 @@ module.exports = {
27 enableInSFC: false, 54 enableInSFC: false,
28 }, 55 },
29 }, 56 },
30 chainWebpack: (config) => { 57 chainWebpack: config => {
31 config.plugins.delete("prefetch"); 58 config.plugins.delete("prefetch");
32 }, 59 },
33 configureWebpack: { 60 configureWebpack: {
34 devtool: "source-map" 61 devtool: "source-map",
35 }, 62 },
36 productionSourceMap: false, 63 productionSourceMap: false,
37 devServer: { 64 devServer: {
38 port: process.env.VUE_APP_DEVSERVER_PORT, 65 port: process.env.VUE_APP_DEVSERVER_PORT,
39 serveIndex: true, 66 serveIndex: true,
40 before: (app, server, compiler) => { 67 proxy: dev_ready && dev_isproxy ? dev_proxyconfig : undefined,
41 app.get(`/${process.env.VUE_APP_DATA_URL}*`, (req, res) => { 68 before: dev_ready && !dev_isproxy ? dev_fsconfig : undefined,
42 const fs = require("fs"); 69 },
43 const url = req.url.slice(process.env.VUE_APP_DATA_URL.length);
44 const paramIdx = url.indexOf("?");
45 const filepath = paramIdx < 0 ? url : url.substring(0, paramIdx);
46 const fullpath = `${process.env.VUE_APP_DEVSERVER_CONFIG_PATH}${decodeURIComponent(filepath)}`;
47 const file = fs.readFileSync(fullpath);
48 res.end(file);
49 });
50 }
51 }
52}; 70};