"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.routes = exports.extractor = exports.PORT = exports.PRODUCTION = void 0;

var _path = _interopRequireDefault(require("path"));

var _fsExtra = _interopRequireDefault(require("fs-extra"));

var _dotenvSafe = _interopRequireDefault(require("dotenv-safe"));

var _server = require("@loadable/server");

_dotenvSafe.default.config({
  allowEmptyValues: true,
  path: _path.default.resolve(__dirname, "../../.env"),
  example: _path.default.resolve(__dirname, "../../.env.example")
}); // Env constants
// ---


const PRODUCTION = process.env.NODE_ENV === "production";
exports.PRODUCTION = PRODUCTION;
const PORT = process.env.PORT || "3000"; // Build thingies
// ---

exports.PORT = PORT;

const getExtractor = () => {
  const file = _path.default.resolve(__dirname, "../loadable-stats.json");

  if (!PRODUCTION && !_fsExtra.default.existsSync(file)) {
    // eslint-disable-next-line no-console
    console.log("Waiting for 'webpack-dev-server'");
    process.exit(0);
  }

  return new _server.ChunkExtractor({
    statsFile: file,
    entrypoints: ["app"]
  });
};

const extractor = getExtractor();
exports.extractor = extractor;
const routes = ["/"].concat(_fsExtra.default.readdirSync(_path.default.resolve(__dirname, "../app/pages")).filter(folder => folder !== "Index").map(folder => `/${folder.toLowerCase()}`));
exports.routes = routes;