chore: fixes for vite dev server (#2678)

This commit is contained in:
kloon15 2023-08-29 20:14:45 +02:00 committed by GitHub
parent a404fb043d
commit aa00c1c89c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 2 deletions

2
frontend/.prettierignore Normal file
View File

@ -0,0 +1,2 @@
# Ignore artifacts:
dist

View File

@ -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",

View File

@ -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%",

View File

@ -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",
},
},