Skip to content

Commit 05fe738

Browse files
committed
fix(renderer-app): monaco app cannot be opened after a build
1 parent 013ecf9 commit 05fe738

File tree

5 files changed

+97
-7
lines changed

5 files changed

+97
-7
lines changed

desktop/renderer-app/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,21 @@
6767
"@types/webpack-env": "^1.15.2",
6868
"@typescript-eslint/eslint-plugin": "^4.29.1",
6969
"@typescript-eslint/parser": "^4.29.1",
70+
"@vitejs/plugin-react-refresh": "^1.3.3",
7071
"agora-electron-sdk": "3.5.0-rc.4-build.1105",
7172
"copy-webpack-plugin": "^9.0.1",
7273
"cross-env": "^7.0.3",
7374
"css-loader": "^5.2.4",
7475
"dotenv-flow": "^3.2.0",
7576
"dotenv-flow-webpack": "^1.1.0",
7677
"electron": "12.0.15",
78+
"esbuild": "^0.12.20",
7779
"eslint": "^7.26.0",
7880
"eslint-config-prettier": "^8.3.0",
7981
"eslint-config-react-app": "^6.0.0",
8082
"eslint-plugin-eslint-comments": "^3.2.0",
8183
"eslint-plugin-jsx-a11y": "^6.4.1",
8284
"eslint-plugin-prettier": "^3.4.0",
83-
"@vitejs/plugin-react-refresh": "^1.3.3",
84-
"esbuild": "^0.12.20",
8585
"eslint-plugin-react": "^7.24.0",
8686
"eslint-plugin-react-app": "^6.2.2",
8787
"eslint-webpack-plugin": "^3.0.1",
@@ -99,6 +99,7 @@
9999
"react-refresh": "^0.10.0",
100100
"react-resize-detector": "^6.7.5",
101101
"react-transition-group": "^4.4.2",
102+
"rollup-plugin-copy": "^3.4.0",
102103
"rollup-plugin-visualizer": "^5.5.2",
103104
"style-loader": "^2.0.0",
104105
"terser-webpack-plugin": "^5.1.2",

desktop/renderer-app/src/tasks/init-register-apps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const initRegisterApps = (): void => {
6464
const getVSPath = (): string => {
6565
let vsPath;
6666
if (process.env.NODE_ENV === "production") {
67-
vsPath = path.join(__dirname, "static", "monaco-editor", "min", "vs");
67+
vsPath = path.join(__dirname, "monaco-editor", "min", "vs");
6868
} else {
6969
const nodeModulesName = "node_modules";
7070
const nodeModulesEndIndexByPath =

desktop/renderer-app/vite.config.ts

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,51 @@
11
import refresh from "@vitejs/plugin-react-refresh";
22
import { defineConfig } from "vite";
3+
import eslintPlugin from "vite-plugin-eslint";
4+
import { visualizer } from "rollup-plugin-visualizer";
5+
import copy from "rollup-plugin-copy";
6+
import path from "path";
7+
38
// TODO: find new place to store vite-plugin-dotenv
49
import { dotenv } from "../../web/flat-web/scripts/vite-plugin-dotenv";
5-
import { visualizer } from "rollup-plugin-visualizer";
610
import { electron } from "./scripts/vite-plugin-electron";
7-
import eslintPlugin from "vite-plugin-eslint";
811
import {
912
configPath,
1013
typesEntryPath,
1114
i18nEntryPath,
1215
componentsEntryPath,
16+
rootNodeModules,
17+
rendererPath,
1318
} from "../../scripts/constants";
1419

1520
export default defineConfig(() => {
16-
const plugins = [refresh(), dotenv(configPath), electron(), eslintPlugin()];
21+
const plugins = [
22+
refresh(),
23+
dotenv(configPath),
24+
electron(),
25+
eslintPlugin(),
26+
copy({
27+
targets: [
28+
/**
29+
* e.g:
30+
* /Users/black-hole/Code/Job/Agora/flat/node_modules/monaco-editor/min/vs
31+
* to
32+
* /Users/black-hole/Code/Job/Agora/flat/desktop/renderer-app/dist/monaco-editor/min/vs
33+
*/
34+
{
35+
src: path.join(rootNodeModules, "monaco-editor", "min", "vs"),
36+
// don't write "vs". because dist path will is: dist/monaco-editor/min/vs/vs
37+
dest: path.join(rendererPath, "dist", "monaco-editor", "min"),
38+
},
39+
{
40+
src: path.join(rootNodeModules, "monaco-editor", "min-maps", "vs"),
41+
dest: path.join(rendererPath, "dist", "monaco-editor", "min-maps"),
42+
},
43+
],
44+
verbose: true,
45+
// see: https://github.com/vitejs/vite/issues/1231#issuecomment-753549857
46+
hook: "writeBundle",
47+
}),
48+
];
1749
if (process.env.ANALYZER) {
1850
plugins.push({
1951
...visualizer(),

scripts/constants.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ const componentsEntryPath = join(packagesPath, "flat-components", "src");
1818
const rootPackageJSONPath = join(rootPath, "package.json");
1919
const mainPackageJSONPath = join(mainPath, "package.json");
2020

21+
const rootNodeModules = join(rootPath, "node_modules");
22+
2123
const version = require(mainPackageJSONPath).version;
2224

2325
module.exports.rootPath = rootPath;
@@ -39,3 +41,5 @@ module.exports.rootPackageJSONPath = rootPackageJSONPath;
3941
module.exports.mainPackageJSONPath = mainPackageJSONPath;
4042

4143
module.exports.version = version;
44+
45+
module.exports.rootNodeModules = rootNodeModules;

yarn.lock

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3114,6 +3114,13 @@
31143114
resolved "https://registry.yarnpkg.com/@types/faker/-/faker-5.5.8.tgz#6649adfdfdbb0acf95361fc48f2d0ca6e88bd1cf"
31153115
integrity sha512-bsl0rYsaZVHlZkynL5O04q6YXDmVjcid6MbOHWqvtE2WWs/EKhp0qchDDhVWlWyQXUffX1G83X9LnMxRl8S/Mw==
31163116

3117+
"@types/fs-extra@^8.0.1":
3118+
version "8.1.2"
3119+
resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-8.1.2.tgz#7125cc2e4bdd9bd2fc83005ffdb1d0ba00cca61f"
3120+
integrity sha512-SvSrYXfWSc7R4eqnOzbQF4TZmfpNSM9FrSWLU3EUnWBuyZqNBOrv1B1JA3byUDPUl9z4Ab3jeZG2eDdySlgNMg==
3121+
dependencies:
3122+
"@types/node" "*"
3123+
31173124
"@types/fs-extra@^9.0.11":
31183125
version "9.0.12"
31193126
resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-9.0.12.tgz#9b8f27973df8a7a3920e8461517ebf8a7d4fdfaf"
@@ -5906,6 +5913,11 @@ color@^3.1.0:
59065913
color-convert "^1.9.3"
59075914
color-string "^1.6.0"
59085915

5916+
colorette@^1.1.0:
5917+
version "1.4.0"
5918+
resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.4.0.tgz#5190fbb87276259a86ad700bff2c6d6faa3fca40"
5919+
integrity sha512-Y2oEozpomLn7Q3HFP7dpww7AtMJplbM9lGZP6RDfHqmbeRjiwRg4n6VM6j4KLmRke85uWEI7JqF17f3pqdRA0g==
5920+
59095921
colorette@^1.2.1, colorette@^1.2.2:
59105922
version "1.3.0"
59115923
resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.3.0.tgz#ff45d2f0edb244069d3b772adeb04fed38d0a0af"
@@ -8129,6 +8141,17 @@ fast-glob@^2.2.6:
81298141
merge2 "^1.2.3"
81308142
micromatch "^3.1.10"
81318143

8144+
fast-glob@^3.0.3:
8145+
version "3.2.11"
8146+
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.11.tgz#a1172ad95ceb8a16e20caa5c5e56480e5129c1d9"
8147+
integrity sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==
8148+
dependencies:
8149+
"@nodelib/fs.stat" "^2.0.2"
8150+
"@nodelib/fs.walk" "^1.2.3"
8151+
glob-parent "^5.1.2"
8152+
merge2 "^1.3.0"
8153+
micromatch "^4.0.4"
8154+
81328155
fast-glob@^3.1.1, fast-glob@^3.2.5:
81338156
version "3.2.7"
81348157
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.7.tgz#fd6cb7a2d7e9aa7a7846111e85a196d6b2f766a1"
@@ -8987,6 +9010,20 @@ globalthis@^1.0.0, globalthis@^1.0.1:
89879010
dependencies:
89889011
define-properties "^1.1.3"
89899012

9013+
9014+
version "10.0.1"
9015+
resolved "https://registry.yarnpkg.com/globby/-/globby-10.0.1.tgz#4782c34cb75dd683351335c5829cc3420e606b22"
9016+
integrity sha512-sSs4inE1FB2YQiymcmTv6NWENryABjUNPeWhOvmn4SjtKybglsyPZxFB3U1/+L1bYi0rNZDqCLlHyLYDl1Pq5A==
9017+
dependencies:
9018+
"@types/glob" "^7.1.1"
9019+
array-union "^2.1.0"
9020+
dir-glob "^3.0.1"
9021+
fast-glob "^3.0.3"
9022+
glob "^7.1.3"
9023+
ignore "^5.1.1"
9024+
merge2 "^1.2.3"
9025+
slash "^3.0.0"
9026+
89909027
89919028
version "11.0.1"
89929029
resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.1.tgz#9a2bf107a068f3ffeabc49ad702c79ede8cfd357"
@@ -9651,6 +9688,11 @@ ignore@^5.0.5:
96519688
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.9.tgz#9ec1a5cbe8e1446ec60d4420060d43aa6e7382fb"
96529689
integrity sha512-2zeMQpbKz5dhZ9IwL0gbxSW5w0NK/MSAMtNuhgIHEPmaU3vPdKPL0UdvUCXs5SS4JAwsBxysK5sFMW8ocFiVjQ==
96539690

9691+
ignore@^5.1.1:
9692+
version "5.2.0"
9693+
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a"
9694+
integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==
9695+
96549696
ignore@^5.1.4:
96559697
version "5.1.8"
96569698
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.8.tgz#f150a8b50a34289b33e22f5889abd4d8016f0e57"
@@ -10205,7 +10247,7 @@ is-plain-obj@^2.0.0:
1020510247
resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-2.1.0.tgz#45e42e37fccf1f40da8e5f76ee21515840c09287"
1020610248
integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==
1020710249

10208-
10250+
[email protected], is-plain-object@^3.0.0:
1020910251
version "3.0.1"
1021010252
resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-3.0.1.tgz#662d92d24c0aa4302407b0d45d21f2251c85f85b"
1021110253
integrity sha512-Xnpx182SBMrr/aBik8y+GuR4U1L9FqMSojwDQwPMmxyC6bvEqly9UBCxhauBF5vNh2gwWJNX6oDV7O+OM4z34g==
@@ -14683,6 +14725,17 @@ roarr@^2.15.3:
1468314725
semver-compare "^1.0.0"
1468414726
sprintf-js "^1.1.2"
1468514727

14728+
rollup-plugin-copy@^3.4.0:
14729+
version "3.4.0"
14730+
resolved "https://registry.yarnpkg.com/rollup-plugin-copy/-/rollup-plugin-copy-3.4.0.tgz#f1228a3ffb66ffad8606e2f3fb7ff23141ed3286"
14731+
integrity sha512-rGUmYYsYsceRJRqLVlE9FivJMxJ7X6jDlP79fmFkL8sJs7VVMSVyA2yfyL+PGyO/vJs4A87hwhgVfz61njI+uQ==
14732+
dependencies:
14733+
"@types/fs-extra" "^8.0.1"
14734+
colorette "^1.1.0"
14735+
fs-extra "^8.1.0"
14736+
globby "10.0.1"
14737+
is-plain-object "^3.0.0"
14738+
1468614739
rollup-plugin-visualizer@^5.5.2:
1468714740
version "5.5.2"
1468814741
resolved "https://registry.yarnpkg.com/rollup-plugin-visualizer/-/rollup-plugin-visualizer-5.5.2.tgz#ae2130ee5ae4a2d901e764e492b71357cb95eed7"

0 commit comments

Comments
 (0)