You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

13 lines
464 B

1 month ago
  1. /* eslint import/prefer-default-export: off */
  2. const { URL } = require('url');
  3. const { path } = require('path');
  4. function resolveHtmlPath(htmlFileName) {
  5. if (process.env.NODE_ENV === 'development') {
  6. const port = process.env.PORT || 3000;
  7. const url = new URL(`http://localhost:${port}`);
  8. url.pathname = htmlFileName;
  9. return url.href;
  10. }
  11. return `file://${path.resolve(__dirname, './build', htmlFileName)}`;
  12. }
  13. module.exports = resolveHtmlPath