From 89319417f3a6a1cea24127a57e93e4f76e4189fc Mon Sep 17 00:00:00 2001 From: Kai Salmen Date: Fri, 14 Jun 2024 13:49:16 +0200 Subject: [PATCH] fix: web languageId and fileExt replacement / configuration, remove need for http-server --- .../generator-langium/templates/packages/web/package.json | 6 ++---- .../templates/packages/web/src/setupClassic.ts | 3 ++- .../templates/packages/web/src/setupExtended.ts | 6 +++--- packages/generator-langium/test/yeoman-generator.test.ts | 6 ++---- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/packages/generator-langium/templates/packages/web/package.json b/packages/generator-langium/templates/packages/web/package.json index 26999962c..1986a7862 100644 --- a/packages/generator-langium/templates/packages/web/package.json +++ b/packages/generator-langium/templates/packages/web/package.json @@ -12,10 +12,9 @@ ], "scripts": { "build": "vite build", - "bundle:serve": "http-server ./dist --port 5175", "dev": "vite", "dev:debug": "vite --debug --force", - "serve": "npm run dev" + "serve": "vite preview" }, "dependencies": { "@codingame/monaco-vscode-editor-service-override": "~5.2.0", @@ -27,8 +26,7 @@ }, "devDependencies": { "@codingame/esbuild-import-meta-url-plugin": "~1.0.2", - "vite": "~5.2.13", - "http-server": "~14.1.1" + "vite": "~5.2.13" }, "volta": { "node": "18.20.3", diff --git a/packages/generator-langium/templates/packages/web/src/setupClassic.ts b/packages/generator-langium/templates/packages/web/src/setupClassic.ts index 722c33fe1..ce6717d6c 100644 --- a/packages/generator-langium/templates/packages/web/src/setupClassic.ts +++ b/packages/generator-langium/templates/packages/web/src/setupClassic.ts @@ -11,7 +11,8 @@ export const setupConfigClassic = (): UserConfig => { codeResources: { main: { text: '// <%= RawLanguageName %> is running in the web!', - uri: '/workspace/hello-world.<%= file-extension %>', + fileExt: '<%= file-glob-extension %>', + enforceLanguageId: '<%= language-id %>' } }, languageDef: { diff --git a/packages/generator-langium/templates/packages/web/src/setupExtended.ts b/packages/generator-langium/templates/packages/web/src/setupExtended.ts index 080894440..1856348e2 100644 --- a/packages/generator-langium/templates/packages/web/src/setupExtended.ts +++ b/packages/generator-langium/templates/packages/web/src/setupExtended.ts @@ -14,7 +14,7 @@ export const setupConfigExtended = (): UserConfig => { codeResources: { main: { text: '// <%= RawLanguageName %> is running in the web!', - uri: '/workspace/hello-world.<%= file-extension %>', + uri: '/workspace/hello-world.<%= file-glob-extension %>', } }, extensions: [{ @@ -29,7 +29,7 @@ export const setupConfigExtended = (): UserConfig => { languages: [{ id: '<%= language-id %>', extensions: [ - '.<%= language-id %>' + '.<%= file-glob-extension %>' ], configuration: './language-configuration.json' }], @@ -41,7 +41,7 @@ export const setupConfigExtended = (): UserConfig => { } }, filesOrContents: extensionFilesOrContents, - }], + }], userConfiguration: { json: JSON.stringify({ 'workbench.colorTheme': 'Default Dark Modern', diff --git a/packages/generator-langium/test/yeoman-generator.test.ts b/packages/generator-langium/test/yeoman-generator.test.ts index f13dfebbf..147408df9 100644 --- a/packages/generator-langium/test/yeoman-generator.test.ts +++ b/packages/generator-langium/test/yeoman-generator.test.ts @@ -301,10 +301,9 @@ const PACKAGE_JSON_EXPECTATION_WEB: Record = { files: ['out', 'src'], scripts: { 'build': 'vite build', - 'bundle:serve': 'http-server ./dist --port 5175', 'dev': 'vite', 'dev:debug': 'vite --debug --force', - 'serve': 'npm run dev' + 'serve': 'vite preview' }, dependencies: { '@codingame/monaco-vscode-editor-service-override': '~5.2.0', @@ -316,8 +315,7 @@ const PACKAGE_JSON_EXPECTATION_WEB: Record = { }, devDependencies: { '@codingame/esbuild-import-meta-url-plugin': '~1.0.2', - 'vite': '~5.2.13', - 'http-server': '~14.1.1' + 'vite': '~5.2.13' }, volta: { node: '18.20.3',