Skip to content

Commit 013ecf9

Browse files
authored
chore(renderer-app): improve vite config path (#1306)
1 parent e06b553 commit 013ecf9

File tree

2 files changed

+26
-20
lines changed

2 files changed

+26
-20
lines changed

desktop/renderer-app/vite.config.ts

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
import refresh from "@vitejs/plugin-react-refresh";
22
import { defineConfig } from "vite";
3-
import path from "path";
43
// TODO: find new place to store vite-plugin-dotenv
54
import { dotenv } from "../../web/flat-web/scripts/vite-plugin-dotenv";
65
import { visualizer } from "rollup-plugin-visualizer";
76
import { electron } from "./scripts/vite-plugin-electron";
87
import eslintPlugin from "vite-plugin-eslint";
8+
import {
9+
configPath,
10+
typesEntryPath,
11+
i18nEntryPath,
12+
componentsEntryPath,
13+
} from "../../scripts/constants";
914

1015
export default defineConfig(() => {
11-
const plugins = [refresh(), dotenv("../../config"), electron(), eslintPlugin()];
16+
const plugins = [refresh(), dotenv(configPath), electron(), eslintPlugin()];
1217
if (process.env.ANALYZER) {
1318
plugins.push({
1419
...visualizer(),
@@ -28,29 +33,15 @@ export default defineConfig(() => {
2833
},
2934
{
3035
find: "flat-types",
31-
replacement: path.join(__dirname, "..", "..", "packages", "flat-types", "src"),
36+
replacement: typesEntryPath,
3237
},
3338
{
3439
find: "flat-i18n",
35-
replacement: path.join(
36-
__dirname,
37-
"..",
38-
"..",
39-
"packages",
40-
"flat-i18n",
41-
"locales",
42-
),
40+
replacement: i18nEntryPath,
4341
},
4442
{
4543
find: "flat-components",
46-
replacement: path.join(
47-
__dirname,
48-
"..",
49-
"..",
50-
"packages",
51-
"flat-components",
52-
"src",
53-
),
44+
replacement: componentsEntryPath,
5445
},
5546
],
5647
},

scripts/constants.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ const desktopPath = join(rootPath, "desktop");
77
const mainPath = join(desktopPath, "main-app");
88
const rendererPath = join(desktopPath, "renderer-app");
99

10+
const typesPath = join(packagesPath, "flat-types");
11+
const i18nPath = join(packagesPath, "flat-i18n");
12+
const componentsPath = join(packagesPath, "flat-components");
13+
14+
const typesEntryPath = join(packagesPath, "flat-types", "src");
15+
const i18nEntryPath = join(packagesPath, "flat-i18n", "locales");
16+
const componentsEntryPath = join(packagesPath, "flat-components", "src");
17+
1018
const rootPackageJSONPath = join(rootPath, "package.json");
1119
const mainPackageJSONPath = join(mainPath, "package.json");
1220

@@ -19,8 +27,15 @@ module.exports.desktopPath = desktopPath;
1927
module.exports.mainPath = mainPath;
2028
module.exports.rendererPath = rendererPath;
2129

30+
module.exports.typesPath = typesPath;
31+
module.exports.i18nPath = i18nPath;
32+
module.exports.componentsPath = componentsPath;
33+
34+
module.exports.typesEntryPath = typesEntryPath;
35+
module.exports.i18nEntryPath = i18nEntryPath;
36+
module.exports.componentsEntryPath = componentsEntryPath;
37+
2238
module.exports.rootPackageJSONPath = rootPackageJSONPath;
2339
module.exports.mainPackageJSONPath = mainPackageJSONPath;
2440

2541
module.exports.version = version;
26-

0 commit comments

Comments
 (0)