const fs = require("fs");
const path = require("path");

const isCommonsFrontend = !__dirname.includes("node_modules");

const absolutePath = basePath =>
  isCommonsFrontend
    ? path.join(__dirname, "../../../", basePath)
    : path.join(__dirname, "../../../../../../", basePath);

const srcPath = fs.existsSync(absolutePath("src"))
  ? absolutePath("src")
  : absolutePath("app/javascript/src");

module.exports = {
  alias: {
    apis: `${srcPath}/apis`,
    assets: `${srcPath}/assets`,
    components: `${srcPath}/components`,
    hooks: `${srcPath}/hooks`,
    reducers: `${srcPath}/reducers`,
    routes: `${srcPath}/routes`,
    stores: `${srcPath}/stores`,
    translations: `${srcPath}/translations`,
    utils: `${srcPath}/utils`,
    src: srcPath,
    neetoui: "@bigbinary/neetoui",
    neetocommons: "@bigbinary/neeto-commons-frontend",
    neetointegrations: "@bigbinary/neeto-integrations-frontend",
    neetothemes: "@bigbinary/neeto-themes-frontend",
    neetoslack: "@bigbinary/neeto-slack-frontend",
    neetorules: "@bigbinary/neeto-rules-frontend",
    neetoapprovals: "@bigbinary/neeto-approvals-frontend",
    neetofields: "@bigbinary/neeto-fields-frontend",
    neetofolders: "@bigbinary/neeto-folders-frontend",
    neetoredirecturls: "@bigbinary/neeto-redirect-urls-frontend",
    neetogithub: "@bigbinary/neeto-github-frontend",
    neetoratelimit: "@bigbinary/neeto-rate-limit-frontend",
    neetoaccesscontrol: "@bigbinary/neeto-access-control-frontend",
    neetotags: "@bigbinary/neeto-tags-frontend",
    neetoactivities: "@bigbinary/neeto-activities-frontend",
    neetotemplates: "@bigbinary/neeto-templates-frontend",
    neetoapikeys: "@bigbinary/neeto-api-keys-frontend",
    neetoemailnotifications: "@bigbinary/neeto-email-notifications-frontend",
    neetothankyou: "@bigbinary/neeto-thank-you-frontend",
    neetoimageuploader: "@bigbinary/neeto-image-uploader-frontend",
    neetowebhooks: "@bigbinary/neeto-webhooks-frontend",
    neetoform: "@bigbinary/neeto-form-frontend",
    neetoprojects: "@bigbinary/neeto-projects-frontend",
    neetomessagetemplates: "@bigbinary/neeto-message-templates-frontend",
    neetoicons: "@bigbinary/neeto-icons",
    neetoteam: "@bigbinary/neeto-team-members-frontend",
    neetoeditor: "@bigbinary/neeto-editor",
    neetofilters: "@bigbinary/neeto-filters-frontend",
    neetomolecules: "@bigbinary/neeto-molecules",
    neetopayments: "@bigbinary/neeto-payments-frontend",
    neetocist: "@bigbinary/neeto-cist",
    neetohotkeys: "@bigbinary/neeto-hotkeys",
  },
  extensions: [
    ".ts",
    ".mjs",
    ".js",
    ".jsx",
    ".sass",
    ".scss",
    ".css",
    ".module.sass",
    ".module.scss",
    ".module.css",
    ".png",
    ".svg",
    ".gif",
    ".jpeg",
    ".jpg",
  ],
};
