setBasePath.js 542 B

1234567891011121314151617181920
  1. /**
  2. Sets the base path in production for the file protocol, so assets are loaded properly
  3. @module setBasePath
  4. */
  5. const { remote } = require('electron');
  6. const path = require('path');
  7. module.exports = appPath => {
  8. // set the base path for relative assets in production mode
  9. if (remote.getGlobal('production') && ~location.origin.indexOf('file://')) {
  10. window.basePathHref = `${String(
  11. path.resolve(`${__dirname}/../../${appPath}`)
  12. )
  13. .replace(/\\/g, '/')
  14. .replace('/interface', '/app.asar/interface')}/`;
  15. }
  16. };