aboutsummaryrefslogtreecommitdiff
path: root/viewer/vue.config.js
diff options
context:
space:
mode:
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};