diff --git a/packages/xod-client-electron/src/app/utils.js b/packages/xod-client-electron/src/app/utils.js index 8f4bd13d..9be2626d 100644 --- a/packages/xod-client-electron/src/app/utils.js +++ b/packages/xod-client-electron/src/app/utils.js @@ -54,10 +54,28 @@ export const getFilePathToOpen = app => { return () => pathToOpen; }; +/** + * Returns Path to the resources directory root. + * + * When IDE runs in development mode it resolves to directory + * with transpiled code, and it handles call either from Main Process + * and Renderer Process. They're have a different `__dirname` values: + * - Main Process: /some/path/to/src-babel/app + * - Renderer Process: /some/path/to/src-babel + * + * When IDE runs in production mode it resolves to resources path. + */ +export const getResourcesRoot = () => { + if (IS_DEV) { + return process.type === 'renderer' + ? __dirname + : path.resolve(__dirname, '..'); + } + return process.resourcesPath; +}; + /** * Returns Path to the bundled workspace */ export const getPathToBundledWorkspace = () => - IS_DEV - ? path.resolve(__dirname, '../workspace') - : path.resolve(process.resourcesPath, './workspace'); + path.join(getResourcesRoot(), 'workspace'); diff --git a/packages/xod-client-electron/webpack.config.js b/packages/xod-client-electron/webpack.config.js index 6175a516..af3ad198 100644 --- a/packages/xod-client-electron/webpack.config.js +++ b/packages/xod-client-electron/webpack.config.js @@ -9,6 +9,10 @@ const pkgpath = subpath => path.resolve(__dirname, subpath); module.exports = merge.smart(getBaseConfig(__dirname), { target: 'electron-renderer', + node: { + __dirname: false, + __filename: false, + }, entry: [ pkgpath('src/view/styles/main.scss'), ],