From 170d7a61f720ece9dc4b347b19f5a8213f1d8984 Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Sat, 20 Jun 2020 16:50:49 +0200 Subject: viewer: prettier formatting based on eslint-prettier plugin --- viewer/vue.config.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'viewer/vue.config.js') diff --git a/viewer/vue.config.js b/viewer/vue.config.js index f481e4f..9240964 100644 --- a/viewer/vue.config.js +++ b/viewer/vue.config.js @@ -27,11 +27,11 @@ module.exports = { enableInSFC: false, }, }, - chainWebpack: (config) => { + chainWebpack: config => { config.plugins.delete("prefetch"); }, configureWebpack: { - devtool: "source-map" + devtool: "source-map", }, productionSourceMap: false, devServer: { @@ -47,6 +47,6 @@ module.exports = { const file = fs.readFileSync(fullpath); res.end(file); }); - } - } + }, + }, }; -- cgit v1.2.3 From b530f65cf7bc32eb4bb16cf445950a0b1ab685b4 Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Sat, 12 Sep 2020 11:29:57 +0200 Subject: viewer: handle HTTP authentication: DevServer is now able to switch between HTTP proxy and filesystem. --- viewer/vue.config.js | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) (limited to 'viewer/vue.config.js') diff --git a/viewer/vue.config.js b/viewer/vue.config.js index 9240964..8649b6d 100644 --- a/viewer/vue.config.js +++ b/viewer/vue.config.js @@ -17,6 +17,33 @@ -- along with this program. If not, see . */ +/* +-- Create a file .env.development.local in the project to customize your DevServer +-- VUE_APP_DEVSERVER_CONFIG_PATH= will use the dev_proxyconfig +-- VUE_APP_DEVSERVER_CONFIG_PATH= will use the dev_fsconfig +*/ +const dev_ready = Boolean(process.env.VUE_APP_DEVSERVER_CONFIG_PATH); +const dev_isproxy = dev_ready && Boolean(process.env.VUE_APP_DEVSERVER_CONFIG_PATH.match(/^https?:\/\//i)); +const dev_localpath = `^/${process.env.VUE_APP_DATA_URL}`; +const dev_proxyconfig = { + [dev_localpath]: { + target: process.env.VUE_APP_DEVSERVER_CONFIG_PATH, + pathRewrite: { [dev_localpath]: "" }, + }, +}; +const dev_fsconfig = (app, server, compiler) => { + app.get(`${dev_localpath}*`, (req, res) => { + const fs = require("fs"); + const url = req.url.slice(process.env.VUE_APP_DATA_URL.length); + const paramIdx = url.indexOf("?"); + const filepath = paramIdx < 0 ? url : url.substring(0, paramIdx); + const fullpath = `${process.env.VUE_APP_DEVSERVER_CONFIG_PATH}${decodeURIComponent(filepath)}`; + const file = fs.readFileSync(fullpath); + res.end(file); + }); +}; +// ================= + module.exports = { publicPath: "./", pluginOptions: { @@ -37,16 +64,7 @@ module.exports = { devServer: { port: process.env.VUE_APP_DEVSERVER_PORT, serveIndex: true, - before: (app, server, compiler) => { - app.get(`/${process.env.VUE_APP_DATA_URL}*`, (req, res) => { - const fs = require("fs"); - const url = req.url.slice(process.env.VUE_APP_DATA_URL.length); - const paramIdx = url.indexOf("?"); - const filepath = paramIdx < 0 ? url : url.substring(0, paramIdx); - const fullpath = `${process.env.VUE_APP_DEVSERVER_CONFIG_PATH}${decodeURIComponent(filepath)}`; - const file = fs.readFileSync(fullpath); - res.end(file); - }); - }, + proxy: dev_ready && dev_isproxy ? dev_proxyconfig : undefined, + before: dev_ready && !dev_isproxy ? dev_fsconfig : undefined, }, }; -- cgit v1.2.3