webapp: Migrated from vue-cli to vite

This commit is contained in:
Thomas Basler 2022-10-17 19:18:45 +02:00
parent f1e30a743a
commit d798963df5
17 changed files with 797 additions and 5335 deletions

14
webapp/.eslintrc.cjs Normal file
View File

@ -0,0 +1,14 @@
/* eslint-env node */
require('@rushstack/eslint-patch/modern-module-resolution')
module.exports = {
root: true,
'extends': [
'plugin:vue/vue3-essential',
'eslint:recommended',
'@vue/eslint-config-typescript'
],
parserOptions: {
ecmaVersion: 'latest'
}
}

27
webapp/.gitignore vendored
View File

@ -1,21 +1,26 @@
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
.DS_Store
dist
dist-ssr
coverage
*.local
/cypress/videos/
/cypress/screenshots/
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.vscode
*.suo
*.ntvs*
*.njsproj

3
webapp/.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"]
}

View File

@ -1,24 +1,25 @@
# opendtu
## Project setup
```
## Project Setup
```sh
yarn install
```
### Compiles and hot-reloads for development
```
yarn serve
### Compile and Hot-Reload for Development
```sh
yarn dev
```
### Compiles and minifies for production
```
### Type-Check, Compile and Minify for Production
```sh
yarn build
```
### Lints and fixes files
```
### Lint with [ESLint](https://eslint.org/)
```sh
yarn lint
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).

View File

@ -1,5 +0,0 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
}

1
webapp/env.d.ts vendored Normal file
View File

@ -0,0 +1 @@
/// <reference types="vite/client" />

16
webapp/index.html Normal file
View File

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>OpenDTU</title>
</head>
<body>
<noscript>
<strong>We're sorry but OpenDTU doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>

View File

@ -3,57 +3,36 @@
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
"dev": "vite",
"build": "run-p type-check build-only",
"preview": "vite preview --port 4173",
"build-only": "vite build",
"type-check": "vue-tsc --noEmit",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
},
"dependencies": {
"@popperjs/core": "^2.11.6",
"bootstrap": "^5.2.2",
"bootstrap-icons-vue": "^1.8.1",
"core-js": "^3.25.5",
"spark-md5": "^3.0.2",
"vue": "^3.2.40",
"vue-class-component": "^8.0.0-0",
"vue-router": "^4.1.5"
},
"devDependencies": {
"@babel/core": "^7.19.3",
"@babel/eslint-parser": "^7.19.1",
"@rushstack/eslint-patch": "^1.2.0",
"@types/bootstrap": "^5.2.5",
"@types/node": "^18.8.3",
"@types/spark-md5": "^3.0.2",
"@typescript-eslint/parser": "^5.38.1",
"@vue/cli-plugin-babel": "~5.0.8",
"@vue/cli-plugin-eslint": "~5.0.8",
"@vue/cli-plugin-router": "^5.0.6",
"@vue/cli-plugin-typescript": "^5.0.8",
"@vue/cli-service": "~5.0.8",
"@vitejs/plugin-vue": "^3.1.2",
"@vue/eslint-config-typescript": "^11.0.2",
"@vue/tsconfig": "^0.1.3",
"eslint": "^8.25.0",
"eslint-plugin-vue": "^9.6.0",
"npm-run-all": "^4.1.5",
"typescript": "^4.8.4",
"vue-cli-plugin-compression": "~2.0.0"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/vue3-essential",
"eslint:recommended",
"@vue/typescript/recommended"
],
"parserOptions": {
"ecmaVersion": 2021
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead",
"not ie 11"
]
"vite": "^3.1.8",
"vite-plugin-compression": "^0.5.1",
"vite-plugin-css-injected-by-js": "^2.1.0",
"vue-tsc": "^1.0.8"
}
}

View File

@ -1,17 +0,0 @@
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

View File

@ -1,4 +1,4 @@
import { createWebHistory, createRouter, RouteRecordRaw } from 'vue-router';
import { createRouter, createWebHistory } from 'vue-router';
import HomeView from '@/views/HomeView.vue'
import AboutView from '@/views/AboutView.vue'
import NetworkInfoView from '@/views/NetworkInfoView.vue'
@ -14,7 +14,10 @@ import FirmwareUpgradeView from '@/views/FirmwareUpgradeView.vue'
import ConfigAdminView from '@/views/ConfigAdminView.vue'
import SecurityAdminView from '@/views/SecurityAdminView.vue'
const routes: Array<RouteRecordRaw> = [
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
linkActiveClass: "active",
routes: [
{
path: '/',
name: 'Home',
@ -85,12 +88,7 @@ const routes: Array<RouteRecordRaw> = [
name: 'Security',
component: SecurityAdminView
}
];
const router = createRouter({
history: createWebHistory(),
routes,
linkActiveClass: "active",
});
]
})
export default router;

View File

@ -1,6 +0,0 @@
/* eslint-disable */
declare module '*.vue' {
import type { DefineComponent } from 'vue'
const component: DefineComponent<{}, {}, any>
export default component
}

View File

@ -350,7 +350,8 @@ declare interface Inverter {
limit_relative: 0,
limit_absolute: 0,
data_age: 0,
events: 0
events: 0,
[key: number]: any,
}
export default defineComponent({

View File

@ -0,0 +1,8 @@
{
"extends": "@vue/tsconfig/tsconfig.node.json",
"include": ["vite.config.*", "vitest.config.*", "cypress.config.*"],
"compilerOptions": {
"composite": true,
"types": ["node"]
}
}

View File

@ -1,41 +1,16 @@
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"moduleResolution": "node",
"experimentalDecorators": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"useDefineForClassFields": true,
"sourceMap": true,
"baseUrl": ".",
"types": [
"webpack-env"
],
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx"
],
"exclude": [
"node_modules"
]
"extends": "@vue/tsconfig/tsconfig.web.json",
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},
"references": [
{
"path": "./tsconfig.config.json"
}
]
}

48
webapp/vite.config.ts Normal file
View File

@ -0,0 +1,48 @@
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import viteCompression from 'vite-plugin-compression';
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
viteCompression({ deleteOriginFile: true, threshold: 0 }),
cssInjectedByJsPlugin()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
build: {
// Prevent vendor.css being created
cssCodeSplit: false,
outDir: '../webapp_dist',
emptyOutDir: true,
rollupOptions: {
output: {
// Only create one js file
inlineDynamicImports: true,
// Get rid of hash on js file
entryFileNames: 'js/app.js',
// Get rid of hash on css file
assetFileNames: "assets/[name].[ext]",
},
},
},
server: {
proxy: {
'^/api': {
target: 'http://192.168.20.110/'
},
'^/livedata': {
target: 'ws://192.168.20.110/',
ws: true,
changeOrigin: true
}
}
}
})

View File

@ -1,38 +0,0 @@
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true,
productionSourceMap: false,
outputDir: '../webapp_dist',
filenameHashing: false,
css: {
extract: false,
},
configureWebpack: {
optimization: {
splitChunks: false
}
},
pluginOptions: {
compression: {
gzip: {
filename: '[file].gz[query]',
algorithm: 'gzip',
include: /\.(js|css|html|svg|json)(\?.*)?$/i,
deleteOriginalAssets: true,
minRatio: 0.8,
}
}
},
devServer: {
proxy: {
'^/api': {
target: 'http://192.168.20.110/'
},
'^/livedata': {
target: 'ws://192.168.20.110/',
ws: true,
changeOrigin: true
}
}
}
})

File diff suppressed because it is too large Load Diff