Skip to content

Commit

Permalink
fix(renderer-app): monaco-editor load failed in windows system (#999)
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackHole1 committed Oct 14, 2021
1 parent dd1069e commit 388ea3f
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions desktop/renderer-app/src/tasks/init-register-apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const registerApps = async (): Promise<void> => {
appOptions: {
loader: {
paths: {
vs: `file://${getVSPath()}`,
vs: getVSPath(),
},
},
},
Expand All @@ -23,14 +23,18 @@ export const initRegisterApps = async (): Promise<void> => {
};

const getVSPath = (): string => {
let vsPath;
if (process.env.NODE_ENV === "production") {
return path.join(__dirname, "static", "monaco-editor", "min", "vs");
}
vsPath = path.join(__dirname, "static", "monaco-editor", "min", "vs");
} else {
const nodeModulesName = "node_modules";
const nodeModulesEndIndexByPath =
__dirname.indexOf(nodeModulesName) + nodeModulesName.length;

const nodeModulesName = "node_modules";
const nodeModulesEndIndexByPath = __dirname.indexOf(nodeModulesName) + nodeModulesName.length;
const rootNodeModulesPath = __dirname.slice(0, nodeModulesEndIndexByPath);

const rootNodeModulesPath = __dirname.slice(0, nodeModulesEndIndexByPath);
vsPath = path.join(rootNodeModulesPath, "monaco-editor", "min", "vs");
}

return path.join(rootNodeModulesPath, "monaco-editor", "min", "vs");
return `file:///${vsPath.replace(/\\/g, "/")}`;
};

0 comments on commit 388ea3f

Please sign in to comment.