From aa00c1c89cbdde4d123e58daecfdaaa3861c6b01 Mon Sep 17 00:00:00 2001 From: kloon15 Date: Tue, 29 Aug 2023 20:14:45 +0200 Subject: [PATCH] chore: fixes for vite dev server (#2678) --- frontend/.prettierignore | 2 ++ frontend/package-lock.json | 27 ++++++++++++++++++++++++++- frontend/package.json | 3 ++- frontend/vite.config.js | 6 ++++++ 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 frontend/.prettierignore diff --git a/frontend/.prettierignore b/frontend/.prettierignore new file mode 100644 index 00000000..780b4555 --- /dev/null +++ b/frontend/.prettierignore @@ -0,0 +1,2 @@ +# Ignore artifacts: +dist \ No newline at end of file diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 6761ffcd..ee68ed90 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -47,7 +47,8 @@ "prettier": "^3.0.1", "terser": "^5.19.2", "vite": "^4.4.9", - "vite-plugin-compression2": "^0.10.3" + "vite-plugin-compression2": "^0.10.3", + "vite-plugin-rewrite-all": "^1.0.1" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -2865,6 +2866,15 @@ "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", "dev": true }, + "node_modules/connect-history-api-fallback": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/connect-history-api-fallback/-/connect-history-api-fallback-1.6.0.tgz", + "integrity": "sha512-e54B99q/OUoH64zYYRf3HBP5z24G38h5D3qXu23JGRoigpX5Ss4r9ZnDk3g0Z8uQC2x2lPaJ+UlWBc1ZWBWdLg==", + "dev": true, + "engines": { + "node": ">=0.8" + } + }, "node_modules/convert-source-map": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", @@ -5716,6 +5726,21 @@ "@rollup/pluginutils": "^5.0.2" } }, + "node_modules/vite-plugin-rewrite-all": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/vite-plugin-rewrite-all/-/vite-plugin-rewrite-all-1.0.1.tgz", + "integrity": "sha512-W0DAchC8ynuQH0lYLIu5/5+JGfYlUTRD8GGNtHFXRJX4FzzB9MajtqHBp26zq/ly9sDt5BqrfdT08rv3RbB0LQ==", + "dev": true, + "dependencies": { + "connect-history-api-fallback": "^1.6.0" + }, + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "vite": "^2.0.0 || ^3.0.0 || ^4.0.0" + } + }, "node_modules/vue": { "version": "2.7.14", "resolved": "https://registry.npmjs.org/vue/-/vue-2.7.14.tgz", diff --git a/frontend/package.json b/frontend/package.json index 18282c40..5284104e 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -53,7 +53,8 @@ "prettier": "^3.0.1", "terser": "^5.19.2", "vite": "^4.4.9", - "vite-plugin-compression2": "^0.10.3" + "vite-plugin-compression2": "^0.10.3", + "vite-plugin-rewrite-all": "^1.0.1" }, "browserslist": [ "> 1%", diff --git a/frontend/vite.config.js b/frontend/vite.config.js index 6c6052c8..a5329717 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -4,6 +4,7 @@ import { defineConfig } from "vite"; import legacy from "@vitejs/plugin-legacy"; import vue2 from "@vitejs/plugin-vue2"; import { compression } from "vite-plugin-compression2"; +import pluginRewriteAll from "vite-plugin-rewrite-all"; const plugins = [ vue2(), @@ -12,6 +13,7 @@ const plugins = [ additionalLegacyPolyfills: ["regenerator-runtime/runtime"], }), compression({ include: /\.js$/i, deleteOriginalAssets: true }), + pluginRewriteAll(), // fixes 404 error with paths containing dot in dev server ]; const resolve = { @@ -29,6 +31,10 @@ export default defineConfig(({ command }) => { resolve, server: { proxy: { + "/api/command": { + target: "ws://127.0.0.1:8080", + ws: true, + }, "/api": "http://127.0.0.1:8080", }, },