summaryrefslogtreecommitdiff
path: root/src/utils/directories.ts
blob: b754797eb90c902e49b2eeb18fec12c0836ef991 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import path from 'path';
import { fileURLToPath } from 'url';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

/** */
export const getProjectRootDir = (): string => {
  const mode = import.meta.env.MODE;

  return mode === 'production' ? path.join(__dirname, '../') : path.join(__dirname, '../../');
};

const __srcFolder = path.join(getProjectRootDir(), '/src');

/** */
export const getRelativeUrlByFilePath = (filepath: string): string => {
  return filepath.replace(__srcFolder, '');
};