webapp: Migrated from vue-cli to vite
This commit is contained in:
parent
f1e30a743a
commit
d798963df5
14
webapp/.eslintrc.cjs
Normal file
14
webapp/.eslintrc.cjs
Normal 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
27
webapp/.gitignore
vendored
@ -1,21 +1,26 @@
|
|||||||
.DS_Store
|
# Logs
|
||||||
node_modules
|
logs
|
||||||
/dist
|
*.log
|
||||||
|
|
||||||
|
|
||||||
# local env files
|
|
||||||
.env.local
|
|
||||||
.env.*.local
|
|
||||||
|
|
||||||
# Log files
|
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
pnpm-debug.log*
|
pnpm-debug.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
node_modules
|
||||||
|
.DS_Store
|
||||||
|
dist
|
||||||
|
dist-ssr
|
||||||
|
coverage
|
||||||
|
*.local
|
||||||
|
|
||||||
|
/cypress/videos/
|
||||||
|
/cypress/screenshots/
|
||||||
|
|
||||||
# Editor directories and files
|
# Editor directories and files
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/extensions.json
|
||||||
.idea
|
.idea
|
||||||
.vscode
|
|
||||||
*.suo
|
*.suo
|
||||||
*.ntvs*
|
*.ntvs*
|
||||||
*.njsproj
|
*.njsproj
|
||||||
|
|||||||
3
webapp/.vscode/extensions.json
vendored
Normal file
3
webapp/.vscode/extensions.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"]
|
||||||
|
}
|
||||||
@ -1,24 +1,25 @@
|
|||||||
# opendtu
|
# opendtu
|
||||||
|
|
||||||
## Project setup
|
## Project Setup
|
||||||
```
|
|
||||||
|
```sh
|
||||||
yarn install
|
yarn install
|
||||||
```
|
```
|
||||||
|
|
||||||
### Compiles and hot-reloads for development
|
### Compile and Hot-Reload for Development
|
||||||
```
|
|
||||||
yarn serve
|
```sh
|
||||||
|
yarn dev
|
||||||
```
|
```
|
||||||
|
|
||||||
### Compiles and minifies for production
|
### Type-Check, Compile and Minify for Production
|
||||||
```
|
|
||||||
|
```sh
|
||||||
yarn build
|
yarn build
|
||||||
```
|
```
|
||||||
|
|
||||||
### Lints and fixes files
|
### Lint with [ESLint](https://eslint.org/)
|
||||||
```
|
|
||||||
yarn lint
|
|
||||||
```
|
|
||||||
|
|
||||||
### Customize configuration
|
```sh
|
||||||
See [Configuration Reference](https://cli.vuejs.org/config/).
|
yarn lint
|
||||||
|
```
|
||||||
@ -1,5 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
presets: [
|
|
||||||
'@vue/cli-plugin-babel/preset'
|
|
||||||
]
|
|
||||||
}
|
|
||||||
1
webapp/env.d.ts
vendored
Normal file
1
webapp/env.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/// <reference types="vite/client" />
|
||||||
16
webapp/index.html
Normal file
16
webapp/index.html
Normal 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>
|
||||||
@ -3,57 +3,36 @@
|
|||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"serve": "vue-cli-service serve",
|
"dev": "vite",
|
||||||
"build": "vue-cli-service build",
|
"build": "run-p type-check build-only",
|
||||||
"lint": "vue-cli-service lint"
|
"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": {
|
"dependencies": {
|
||||||
"@popperjs/core": "^2.11.6",
|
"@popperjs/core": "^2.11.6",
|
||||||
"bootstrap": "^5.2.2",
|
"bootstrap": "^5.2.2",
|
||||||
"bootstrap-icons-vue": "^1.8.1",
|
"bootstrap-icons-vue": "^1.8.1",
|
||||||
"core-js": "^3.25.5",
|
|
||||||
"spark-md5": "^3.0.2",
|
"spark-md5": "^3.0.2",
|
||||||
"vue": "^3.2.40",
|
"vue": "^3.2.40",
|
||||||
"vue-class-component": "^8.0.0-0",
|
|
||||||
"vue-router": "^4.1.5"
|
"vue-router": "^4.1.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.19.3",
|
"@rushstack/eslint-patch": "^1.2.0",
|
||||||
"@babel/eslint-parser": "^7.19.1",
|
|
||||||
"@types/bootstrap": "^5.2.5",
|
"@types/bootstrap": "^5.2.5",
|
||||||
"@types/node": "^18.8.3",
|
"@types/node": "^18.8.3",
|
||||||
"@types/spark-md5": "^3.0.2",
|
"@types/spark-md5": "^3.0.2",
|
||||||
"@typescript-eslint/parser": "^5.38.1",
|
"@vitejs/plugin-vue": "^3.1.2",
|
||||||
"@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",
|
|
||||||
"@vue/eslint-config-typescript": "^11.0.2",
|
"@vue/eslint-config-typescript": "^11.0.2",
|
||||||
|
"@vue/tsconfig": "^0.1.3",
|
||||||
"eslint": "^8.25.0",
|
"eslint": "^8.25.0",
|
||||||
"eslint-plugin-vue": "^9.6.0",
|
"eslint-plugin-vue": "^9.6.0",
|
||||||
|
"npm-run-all": "^4.1.5",
|
||||||
"typescript": "^4.8.4",
|
"typescript": "^4.8.4",
|
||||||
"vue-cli-plugin-compression": "~2.0.0"
|
"vite": "^3.1.8",
|
||||||
},
|
"vite-plugin-compression": "^0.5.1",
|
||||||
"eslintConfig": {
|
"vite-plugin-css-injected-by-js": "^2.1.0",
|
||||||
"root": true,
|
"vue-tsc": "^1.0.8"
|
||||||
"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"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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>
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import { createWebHistory, createRouter, RouteRecordRaw } from 'vue-router';
|
import { createRouter, createWebHistory } from 'vue-router';
|
||||||
import HomeView from '@/views/HomeView.vue'
|
import HomeView from '@/views/HomeView.vue'
|
||||||
import AboutView from '@/views/AboutView.vue'
|
import AboutView from '@/views/AboutView.vue'
|
||||||
import NetworkInfoView from '@/views/NetworkInfoView.vue'
|
import NetworkInfoView from '@/views/NetworkInfoView.vue'
|
||||||
@ -14,7 +14,10 @@ import FirmwareUpgradeView from '@/views/FirmwareUpgradeView.vue'
|
|||||||
import ConfigAdminView from '@/views/ConfigAdminView.vue'
|
import ConfigAdminView from '@/views/ConfigAdminView.vue'
|
||||||
import SecurityAdminView from '@/views/SecurityAdminView.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: '/',
|
path: '/',
|
||||||
name: 'Home',
|
name: 'Home',
|
||||||
@ -85,12 +88,7 @@ const routes: Array<RouteRecordRaw> = [
|
|||||||
name: 'Security',
|
name: 'Security',
|
||||||
component: SecurityAdminView
|
component: SecurityAdminView
|
||||||
}
|
}
|
||||||
];
|
]
|
||||||
|
})
|
||||||
const router = createRouter({
|
|
||||||
history: createWebHistory(),
|
|
||||||
routes,
|
|
||||||
linkActiveClass: "active",
|
|
||||||
});
|
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
6
webapp/src/shims-vue.d.ts
vendored
6
webapp/src/shims-vue.d.ts
vendored
@ -1,6 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
declare module '*.vue' {
|
|
||||||
import type { DefineComponent } from 'vue'
|
|
||||||
const component: DefineComponent<{}, {}, any>
|
|
||||||
export default component
|
|
||||||
}
|
|
||||||
@ -350,7 +350,8 @@ declare interface Inverter {
|
|||||||
limit_relative: 0,
|
limit_relative: 0,
|
||||||
limit_absolute: 0,
|
limit_absolute: 0,
|
||||||
data_age: 0,
|
data_age: 0,
|
||||||
events: 0
|
events: 0,
|
||||||
|
[key: number]: any,
|
||||||
}
|
}
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
|
|||||||
8
webapp/tsconfig.config.json
Normal file
8
webapp/tsconfig.config.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"extends": "@vue/tsconfig/tsconfig.node.json",
|
||||||
|
"include": ["vite.config.*", "vitest.config.*", "cypress.config.*"],
|
||||||
|
"compilerOptions": {
|
||||||
|
"composite": true,
|
||||||
|
"types": ["node"]
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,41 +1,16 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"extends": "@vue/tsconfig/tsconfig.web.json",
|
||||||
"target": "esnext",
|
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
|
||||||
"module": "esnext",
|
"compilerOptions": {
|
||||||
"strict": true,
|
"baseUrl": ".",
|
||||||
"jsx": "preserve",
|
"paths": {
|
||||||
"moduleResolution": "node",
|
"@/*": ["./src/*"]
|
||||||
"experimentalDecorators": true,
|
}
|
||||||
"skipLibCheck": true,
|
},
|
||||||
"esModuleInterop": true,
|
|
||||||
"allowSyntheticDefaultImports": true,
|
"references": [
|
||||||
"forceConsistentCasingInFileNames": true,
|
{
|
||||||
"useDefineForClassFields": true,
|
"path": "./tsconfig.config.json"
|
||||||
"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"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|||||||
48
webapp/vite.config.ts
Normal file
48
webapp/vite.config.ts
Normal 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
@ -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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
5797
webapp/yarn.lock
5797
webapp/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user