From 77c7eacc0147d978781d9a32e214e1de12d48677 Mon Sep 17 00:00:00 2001 From: Ionut Pasca Date: Tue, 3 Dec 2024 12:52:41 +0200 Subject: [PATCH] Add jsconfig file in nextjs project --- .../locale-mapper-component.ts | 2 +- .../src/internationalization/project.ts | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/packages/teleport-project-generator-next/src/internationalization/locale-mapper-component.ts b/packages/teleport-project-generator-next/src/internationalization/locale-mapper-component.ts index 56284519f..ad9488a36 100644 --- a/packages/teleport-project-generator-next/src/internationalization/locale-mapper-component.ts +++ b/packages/teleport-project-generator-next/src/internationalization/locale-mapper-component.ts @@ -29,7 +29,7 @@ export const USE_ROUTER_HOOK: UIDLExternalDependency = { export const USE_GLOBAL_CONTEXT_HOOK: UIDLDependency = { type: 'local', - path: '../global-context', + path: '@/global-context', meta: { namedImport: true, }, diff --git a/packages/teleport-project-generator-next/src/internationalization/project.ts b/packages/teleport-project-generator-next/src/internationalization/project.ts index 15a5ecf70..6ea6c7b66 100644 --- a/packages/teleport-project-generator-next/src/internationalization/project.ts +++ b/packages/teleport-project-generator-next/src/internationalization/project.ts @@ -42,6 +42,18 @@ const findFileInTemplate = ( return file } +const generateJsConfigFile = () => { + return ` +{ + "compilerOptions": { + "baseUrl": ".", + "paths": { + "@/*": ["./*"] + } + } +}` +} + const generateGlobalContextFileContent = ( locales: Record, main: { @@ -151,6 +163,18 @@ export class NextProjectPlugini18nConfig implements ProjectPlugin { ], }) + const jsConfigFile = generateJsConfigFile() + files.set('jsconfig.json', { + path: [], + files: [ + { + name: 'jsconfig', + content: jsConfigFile, + fileType: FileType.JSON, + }, + ], + }) + return structure } }