diff options
author | pacien | 2022-09-03 01:34:26 +0200 |
---|---|---|
committer | pacien | 2022-09-03 01:34:26 +0200 |
commit | a8452594c6571e8003baa2aca14747eeeee08152 (patch) | |
tree | a894d99c22a601197869c7a6928d40bb4ae2c392 /viewer/vue.config.js | |
parent | dd9c9804e9e3da9880c711f53edb9c4a19d782f8 (diff) | |
parent | 00510820a2794efcadbc83f7f8b54318fe198ecb (diff) | |
download | ldgallery-a8452594c6571e8003baa2aca14747eeeee08152.tar.gz |
Merge branch 'vue3-refactoring-staging' into develop
Reviewed-by: pacien <pacien.trangirard@pacien.net>
Diffstat (limited to 'viewer/vue.config.js')
-rw-r--r-- | viewer/vue.config.js | 70 |
1 files changed, 29 insertions, 41 deletions
diff --git a/viewer/vue.config.js b/viewer/vue.config.js index 8649b6d..e49909f 100644 --- a/viewer/vue.config.js +++ b/viewer/vue.config.js | |||
@@ -1,7 +1,7 @@ | |||
1 | /* ldgallery - A static generator which turns a collection of tagged | 1 | /* ldgallery - A static generator which turns a collection of tagged |
2 | -- pictures into a searchable web gallery. | 2 | -- pictures into a searchable web gallery. |
3 | -- | 3 | -- |
4 | -- Copyright (C) 2019-2020 Guillaume FOUET | 4 | -- Copyright (C) 2019-2022 Guillaume FOUET |
5 | -- | 5 | -- |
6 | -- This program is free software: you can redistribute it and/or modify | 6 | -- This program is free software: you can redistribute it and/or modify |
7 | -- it under the terms of the GNU Affero General Public License as | 7 | -- it under the terms of the GNU Affero General Public License as |
@@ -22,49 +22,37 @@ | |||
22 | -- VUE_APP_DEVSERVER_CONFIG_PATH=<http_url> will use the dev_proxyconfig | 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 | 23 | -- VUE_APP_DEVSERVER_CONFIG_PATH=<fs_path> will use the dev_fsconfig |
24 | */ | 24 | */ |
25 | const dev_ready = Boolean(process.env.VUE_APP_DEVSERVER_CONFIG_PATH); | ||
26 | const dev_isproxy = dev_ready && Boolean(process.env.VUE_APP_DEVSERVER_CONFIG_PATH.match(/^https?:\/\//i)); | ||
27 | const dev_localpath = `^/${process.env.VUE_APP_DATA_URL}`; | ||
28 | const dev_proxyconfig = { | ||
29 | [dev_localpath]: { | ||
30 | target: process.env.VUE_APP_DEVSERVER_CONFIG_PATH, | ||
31 | pathRewrite: { [dev_localpath]: "" }, | ||
32 | }, | ||
33 | }; | ||
34 | const 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 | 25 | ||
47 | module.exports = { | 26 | const { defineConfig } = require('@vue/cli-service'); |
48 | publicPath: "./", | 27 | const devServer = require('./src/plugins/devServer'); |
28 | |||
29 | module.exports = defineConfig({ | ||
30 | publicPath: './', | ||
31 | transpileDependencies: false, | ||
32 | productionSourceMap: false, | ||
33 | |||
34 | devServer, | ||
49 | pluginOptions: { | 35 | pluginOptions: { |
50 | i18n: { | ||
51 | locale: "en", | ||
52 | fallbackLocale: "en", | ||
53 | localeDir: "locales", | ||
54 | enableInSFC: false, | ||
55 | }, | ||
56 | }, | ||
57 | chainWebpack: config => { | ||
58 | config.plugins.delete("prefetch"); | ||
59 | }, | 36 | }, |
37 | |||
60 | configureWebpack: { | 38 | configureWebpack: { |
61 | devtool: "source-map", | 39 | cache: { |
40 | type: 'filesystem', | ||
41 | }, | ||
62 | }, | 42 | }, |
63 | productionSourceMap: false, | 43 | |
64 | devServer: { | 44 | chainWebpack: config => { |
65 | port: process.env.VUE_APP_DEVSERVER_PORT, | 45 | // Integrates the YAML loader, for i18n files |
66 | serveIndex: true, | 46 | config.module |
67 | proxy: dev_ready && dev_isproxy ? dev_proxyconfig : undefined, | 47 | .rule('yaml') |
68 | before: dev_ready && !dev_isproxy ? dev_fsconfig : undefined, | 48 | .test(/\.ya?ml$/) |
49 | .use('yaml') | ||
50 | .loader('js-yaml-loader'); | ||
51 | config.plugin('define') | ||
52 | .tap(args => { | ||
53 | args[0].__VUE_I18N_FULL_INSTALL__ = false; | ||
54 | args[0].__VUE_I18N_LEGACY_API__ = false; | ||
55 | return args; | ||
56 | }); | ||
69 | }, | 57 | }, |
70 | }; | 58 | }); |