From 11df3493942b4dc42244f1e2edec254dd7d972b7 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Sun, 26 Jun 2022 14:06:49 +0300 Subject: [PATCH] refactor(es modules): set up alias --- src/main.ts | 2 +- src/utils/arrayUtils.ts | 2 +- tsconfig.json | 6 +++++- vite.config.js | 9 ++++++++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main.ts b/src/main.ts index 843d63fe..83b25f64 100644 --- a/src/main.ts +++ b/src/main.ts @@ -13,7 +13,6 @@ import {restoreDefaultEvents} from "./scripts/events"; import {addGlobalListeners} from "./scripts/listeners"; import {locked} from "./scripts/options/lock"; import {clearMainTip, tip} from "./scripts/tooltips"; -import {createTypedArray} from "./utils/arrayUtils"; import { calculateVoronoi, findCell, @@ -23,6 +22,7 @@ import { shouldRegenerateGrid } from "./utils/graphUtils"; import {rn, minmax, normalize} from "./utils/numberUtils"; +import {createTypedArray} from "./utils/arrayUtils"; import {byId} from "./utils/shorthands"; import "./components"; diff --git a/src/utils/arrayUtils.ts b/src/utils/arrayUtils.ts index 9fead55d..3937842c 100644 --- a/src/utils/arrayUtils.ts +++ b/src/utils/arrayUtils.ts @@ -1,4 +1,4 @@ -import {UINT16_MAX, UINT32_MAX, UINT8_MAX} from "../constants"; +import {UINT8_MAX, UINT16_MAX, UINT32_MAX} from "@/constants"; export function last(array: T[]) { return array[array.length - 1]; diff --git a/tsconfig.json b/tsconfig.json index 5bcbb828..2a89fcd4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,7 +14,11 @@ "noUnusedLocals": true, "noUnusedParameters": true, "noImplicitReturns": true, - "skipLibCheck": true + "skipLibCheck": true, + "baseUrl": ".", + "paths": { + "@/*": ["./src/*"] + } }, "include": ["src", "utils", "modules"] } diff --git a/vite.config.js b/vite.config.js index c8a5db6c..b8a9242d 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,5 +1,12 @@ import {defineConfig} from "vite"; +import {fileURLToPath} from "url"; +import path from "path"; export default defineConfig({ - base: "/Fantasy-Map-Generator/" + base: "/Fantasy-Map-Generator/", + resolve: { + alias: { + "@": path.resolve(path.dirname(fileURLToPath(import.meta.url)), "/src") + } + } });