add-default-options.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. "use strict";
  2. var __importDefault = (this && this.__importDefault) || function (mod) {
  3. return (mod && mod.__esModule) ? mod : { "default": mod };
  4. };
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. var utils_1 = require("./utils");
  7. var browser_1 = __importDefault(require("./browser"));
  8. exports.default = (function (window, options) {
  9. // use options from the current script tag data attribues
  10. utils_1.addDataAttr(options, browser_1.default.currentScript(window));
  11. if (options.isFileProtocol === undefined) {
  12. options.isFileProtocol = /^(file|(chrome|safari)(-extension)?|resource|qrc|app):/.test(window.location.protocol);
  13. }
  14. // Load styles asynchronously (default: false)
  15. //
  16. // This is set to `false` by default, so that the body
  17. // doesn't start loading before the stylesheets are parsed.
  18. // Setting this to `true` can result in flickering.
  19. //
  20. options.async = options.async || false;
  21. options.fileAsync = options.fileAsync || false;
  22. // Interval between watch polls
  23. options.poll = options.poll || (options.isFileProtocol ? 1000 : 1500);
  24. options.env = options.env || (window.location.hostname == '127.0.0.1' ||
  25. window.location.hostname == '0.0.0.0' ||
  26. window.location.hostname == 'localhost' ||
  27. (window.location.port &&
  28. window.location.port.length > 0) ||
  29. options.isFileProtocol ? 'development'
  30. : 'production');
  31. var dumpLineNumbers = /!dumpLineNumbers:(comments|mediaquery|all)/.exec(window.location.hash);
  32. if (dumpLineNumbers) {
  33. options.dumpLineNumbers = dumpLineNumbers[1];
  34. }
  35. if (options.useFileCache === undefined) {
  36. options.useFileCache = true;
  37. }
  38. if (options.onReady === undefined) {
  39. options.onReady = true;
  40. }
  41. if (options.relativeUrls) {
  42. options.rewriteUrls = 'all';
  43. }
  44. });
  45. //# sourceMappingURL=add-default-options.js.map