Skip to content

Commit f4b8690

Browse files
committed
[fix] set new basename for the production, use base for vite depending on the environment;
1 parent ea9a78a commit f4b8690

File tree

3 files changed

+58
-44
lines changed

3 files changed

+58
-44
lines changed

.env.production

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ RECORD_MANAGER_APP_TITLE=Record Manager
33
RECORD_MANAGER_APP_INFO=
44
RECORD_MANAGER_LANGUAGE=cs
55
RECORD_MANAGER_NAVIGATOR_LANGUAGE=true
6-
RECORD_MANAGER_BASENAME=/
6+
RECORD_MANAGER_BASENAME=/record-manager
77
RECORD_MANAGER_EXTENSIONS=supplier
88
RECORD_MANAGER_AUTHENTICATION=internal
99
RECORD_MANAGER_AUTH_SERVER_URL=

deploy/internal-auth/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ services:
2525
RECORD_MANAGER_ROOT_PATH: "${RECORD_MANAGER_ROOT_PATH:-/record-manager}"
2626

2727
record-manager:
28-
image: ghcr.io/kbss-cvut/kbss-cvut/record-manager-ui:latest
28+
image: route-nav
2929
container_name: ${RECORD_SET_NAME:-rm}-record-manager
3030
expose:
3131
- "80"

vite.config.js

Lines changed: 56 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,53 +3,67 @@ import { defineConfig } from "vite";
33
import react from "@vitejs/plugin-react";
44
import dotenv from "dotenv";
55
import eslintPlugin from "vite-plugin-eslint";
6+
import { resolve } from "path";
7+
import { readFileSync } from "fs";
68

79
dotenv.config();
810

9-
export default defineConfig({
10-
root: "",
11-
envPrefix: "RECORD_MANAGER_",
12-
plugins: [
13-
react(),
14-
eslintPlugin({
15-
cache: false,
16-
}),
17-
],
18-
build: {
19-
sourcemap: true,
20-
emptyOutDir: true,
21-
rollupOptions: {
22-
onwarn: (warning, defaultHandler) => {
23-
// TODO: workaround for dangerous use of eval method that should be solved in SForms library issue https://github.com/kbss-cvut/s-forms/issues/283
24-
const isFromKbssCvutPackageWarning =
25-
warning.code === "EVAL" && warning.message.includes("node_modules/store/plugins/lib/json2.js");
26-
// TODO: Rollup Pure Annotation warning should be resolved by https://github.com/kbss-cvut/s-forms/issues/282
27-
const isRollupPureAnnotationWarning =
28-
warning.code === "INVALID_ANNOTATION" && warning.message.includes("*#__PURE__*");
29-
if (isFromKbssCvutPackageWarning || isRollupPureAnnotationWarning) {
30-
return;
31-
}
32-
defaultHandler(warning);
11+
function loadEnv(mode) {
12+
const envPath = resolve(process.cwd(), `.env.${mode}`);
13+
const envContent = readFileSync(envPath, "utf-8");
14+
const env = dotenv.parse(envContent);
15+
return env;
16+
}
17+
18+
export default ({ mode }) => {
19+
const env = loadEnv(mode);
20+
21+
return defineConfig({
22+
base: env.RECORD_MANAGER_BASENAME,
23+
root: "",
24+
envPrefix: "RECORD_MANAGER_",
25+
plugins: [
26+
react(),
27+
eslintPlugin({
28+
cache: false,
29+
}),
30+
],
31+
build: {
32+
sourcemap: true,
33+
emptyOutDir: true,
34+
rollupOptions: {
35+
onwarn: (warning, defaultHandler) => {
36+
// TODO: workaround for dangerous use of eval method that should be solved in SForms library issue https://github.com/kbss-cvut/s-forms/issues/283
37+
const isFromKbssCvutPackageWarning =
38+
warning.code === "EVAL" && warning.message.includes("node_modules/store/plugins/lib/json2.js");
39+
// TODO: Rollup Pure Annotation warning should be resolved by https://github.com/kbss-cvut/s-forms/issues/282
40+
const isRollupPureAnnotationWarning =
41+
warning.code === "INVALID_ANNOTATION" && warning.message.includes("*#__PURE__*");
42+
if (isFromKbssCvutPackageWarning || isRollupPureAnnotationWarning) {
43+
return;
44+
}
45+
defaultHandler(warning);
46+
},
3347
},
48+
cssMinify: false, // TODO: workaround for CSS syntax error from SForms library that should be resolved by https://github.com/kbss-cvut/s-forms/issues/283
3449
},
35-
cssMinify: false, // TODO: workaround for CSS syntax error from SForms library that should be resolved by https://github.com/kbss-cvut/s-forms/issues/283
36-
},
37-
define: {
38-
"process.env": process.env, // workaround for parse-link-header library that depends on 2 vars defined in `process.env`, see https://github.com/thlorenz/parse-link-header/issues/31
39-
},
40-
resolve: {
41-
alias: {
42-
querystring: "querystring-es3", // workaround for parse-link-header library that replaces nodejs builtin module with the module adapted for browser
43-
url: "url-parse", // workaround for parse-link-header library that replaces nodejs builtin module with the module adapted for browser
50+
define: {
51+
"process.env": process.env, // workaround for parse-link-header library that depends on 2 vars defined in `process.env`, see https://github.com/thlorenz/parse-link-header/issues/31
52+
},
53+
resolve: {
54+
alias: {
55+
querystring: "querystring-es3", // workaround for parse-link-header library that replaces nodejs builtin module with the module adapted for browser
56+
url: "url-parse", // workaround for parse-link-header library that replaces nodejs builtin module with the module adapted for browser
57+
},
4458
},
45-
},
46-
test: {
47-
environment: "jsdom",
48-
setupFiles: ["./tests/setup.js"],
49-
server: {
50-
deps: {
51-
inline: ["@kbss-cvut/s-forms"],
59+
test: {
60+
environment: "jsdom",
61+
setupFiles: ["./tests/setup.js"],
62+
server: {
63+
deps: {
64+
inline: ["@kbss-cvut/s-forms"],
65+
},
5266
},
5367
},
54-
},
55-
});
68+
});
69+
};

0 commit comments

Comments
 (0)