From 6069b51f8b4a2d2750aea627ef5ec8553387f935 Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Thu, 28 Sep 2023 16:42:07 -0300 Subject: [PATCH] Add `~` as an import alias --- src/js/components/App.tsx | 6 +++--- src/js/components/ResponseRenderer.tsx | 2 +- src/js/hooks/useWebService.ts | 2 +- src/js/index.tsx | 2 +- tsconfig.json | 2 +- webpack.config.js | 1 + 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/js/components/App.tsx b/src/js/components/App.tsx index 671b376..2b6fe83 100644 --- a/src/js/components/App.tsx +++ b/src/js/components/App.tsx @@ -1,7 +1,7 @@ import React from "react"; -import { ErrorRenderer } from "/components/ErrorRenderer"; -import { ResponseRenderer } from "/components/ResponseRenderer"; -import { useWebService } from "/hooks/useWebService"; +import { ErrorRenderer } from "~/components/ErrorRenderer"; +import { ResponseRenderer } from "~/components/ResponseRenderer"; +import { useWebService } from "~/hooks/useWebService"; export function App() { const [response, error] = useWebService(); diff --git a/src/js/components/ResponseRenderer.tsx b/src/js/components/ResponseRenderer.tsx index c0d88b4..ee8dea5 100644 --- a/src/js/components/ResponseRenderer.tsx +++ b/src/js/components/ResponseRenderer.tsx @@ -1,5 +1,5 @@ import React from "react"; -import { TResponse } from "/lib/response"; +import { TResponse } from "~/lib/response"; export function ResponseRenderer({ response }: {response: TResponse}) { const t = chrome.i18n.getMessage; diff --git a/src/js/hooks/useWebService.ts b/src/js/hooks/useWebService.ts index 4166470..3d86eb6 100644 --- a/src/js/hooks/useWebService.ts +++ b/src/js/hooks/useWebService.ts @@ -1,5 +1,5 @@ -import { TResponse, Response } from "/lib/response"; import { useEffect, useState } from "react"; +import { TResponse, Response } from "~/lib/response"; type Maybe = T | null; diff --git a/src/js/index.tsx b/src/js/index.tsx index 5ba1a1f..0d74615 100644 --- a/src/js/index.tsx +++ b/src/js/index.tsx @@ -1,6 +1,6 @@ import React from "react"; import ReactDOM from "react-dom/client"; -import { App } from "/components/App"; +import { App } from "~/components/App"; document.addEventListener("DOMContentLoaded", () => { const el: HTMLElement = document.getElementById("root")!; diff --git a/tsconfig.json b/tsconfig.json index 15a5eaf..5b3b790 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,6 +12,6 @@ "lib": [ "ES2020", "DOM" ], "baseUrl": "src/", - "paths": { "*": ["js/*"] }, + "paths": { "~/*": ["js/*"] }, } } diff --git a/webpack.config.js b/webpack.config.js index 0682059..3849a48 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -14,6 +14,7 @@ module.exports = { path: path.resolve(__dirname, 'build') }, resolve: { + alias: { '~': [path.resolve('src/js/')] }, roots: [path.resolve('src/js'), path.resolve('node_modules')], modules: [path.resolve('src/js'), path.resolve('node_modules')], extensions: ['.ts', '.tsx']