From 58d42839c8bce3d883f347a349ba959d49979ddd Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 24 May 2021 15:25:48 +0200 Subject: [PATCH] Switch to vite --- babel.config.js | 2 +- index.html | 18 + package.json | 23 +- public/index.html | 18 - src/env.d.ts | 9 + src/router/index.ts | 16 +- src/store/index.ts | 2 +- src/styles/main.scss | 4 +- src/views/Error404.vue | 3 +- src/views/Home.vue | 3 +- tsconfig.json | 4 +- vite.config.js | 31 + yarn.lock | 9442 ++++++++-------------------------------- 13 files changed, 2012 insertions(+), 7563 deletions(-) create mode 100644 index.html delete mode 100644 public/index.html create mode 100644 src/env.d.ts create mode 100644 vite.config.js diff --git a/babel.config.js b/babel.config.js index 078c0056..a79d1195 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,3 +1,3 @@ module.exports = { - presets: ['@vue/cli-plugin-babel/preset'], + presets: ['@babel/preset-env'], }; diff --git a/index.html b/index.html new file mode 100644 index 00000000..2b6ad1e9 --- /dev/null +++ b/index.html @@ -0,0 +1,18 @@ + + + + + + + + FreqUI + + + + +
+ + + diff --git a/package.json b/package.json index 1d4248ea..99f6f2dd 100644 --- a/package.json +++ b/package.json @@ -3,12 +3,13 @@ "version": "0.1.0", "private": true, "scripts": { - "serve": "vue-cli-service serve", - "build": "vue-cli-service build", - "test:unit": "vue-cli-service test:unit", - "lint": "vue-cli-service lint", + "serve": "vite", + "dev": "vite", + "build": "vite build --mode prod", + "test:unit": "jest", "check-types": "tsc --noemit", - "lint-ci": "vue-cli-service lint --no-fix", + "lint": "eslint", + "lint-ci": "eslint --no-fix", "cy:open": "cypress open", "cy:run": "cypress run", "cy:open-ct": "cypress open-ct", @@ -37,7 +38,6 @@ "vue-router": "^3.5.3", "vue-select": "^3.16.0", "vuex": "^3.6.2", - "vuex-class": "^0.3.2", "vuex-composition-helpers": "^1.1.0" }, "devDependencies": { @@ -46,13 +46,6 @@ "@types/jest": "^27.4.0", "@typescript-eslint/eslint-plugin": "^2.33.0", "@typescript-eslint/parser": "^5.10.2", - "@vue/cli-plugin-babel": "~4.5.15", - "@vue/cli-plugin-eslint": "~4.5.15", - "@vue/cli-plugin-router": "^4.5.15", - "@vue/cli-plugin-typescript": "~4.5.15", - "@vue/cli-plugin-unit-jest": "~4.5.15", - "@vue/cli-plugin-vuex": "~4.5.15", - "@vue/cli-service": "~4.5.15", "@vue/eslint-config-airbnb": "^5.1.0", "@vue/eslint-config-prettier": "^6.0.0", "@vue/eslint-config-typescript": "^5.1.0", @@ -62,7 +55,7 @@ "eslint-config-airbnb": "^18.2.1", "eslint-plugin-prettier": "^3.4.1", "eslint-plugin-vue": "^7.20.0", - "html-webpack-plugin": "4", + "jest": "~26.6.3", "mutationobserver-shim": "^0.3.7", "popper.js": "^1.16.1", "portal-vue": "^2.1.7", @@ -70,6 +63,8 @@ "sass": "^1.49.7", "sass-loader": "^10.1.1", "typescript": "~4.5.5", + "vite": "^2.3.3", + "vite-plugin-vue2": "^1.5.1", "vue-template-compiler": "^2.6.14", "vuex-class": "^0.3.2" } diff --git a/public/index.html b/public/index.html deleted file mode 100644 index 8910c5bc..00000000 --- a/public/index.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - <%= htmlWebpackPlugin.options.title %> - - - -
- - - diff --git a/src/env.d.ts b/src/env.d.ts new file mode 100644 index 00000000..930d6fe2 --- /dev/null +++ b/src/env.d.ts @@ -0,0 +1,9 @@ +/* Provide Type for Vite's import.meta.env structure */ +interface ImportMeta { + env: { + BASE_URL: string; + MODE: string; + PROD: boolean; + DEV: boolean; + }; +} diff --git a/src/router/index.ts b/src/router/index.ts index ce4cad45..023a5ba8 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -20,27 +20,27 @@ const routes: Array = [ { path: '/trade', name: 'Freqtrade Trading', - component: () => import(/* webpackChunkName: "trade" */ '@/views/Trading.vue'), + component: () => import('@/views/Trading.vue'), }, { path: '/graph', name: 'Freqtrade Graph', - component: () => import(/* webpackChunkName: "graph" */ '@/views/Graphs.vue'), + component: () => import('@/views/Graphs.vue'), }, { path: '/logs', name: 'Freqtrade Logs', - component: () => import(/* webpackChunkName: "graph" */ '@/views/LogView.vue'), + component: () => import('@/views/LogView.vue'), }, { path: '/backtest', name: 'Freqtrade Backtest', - component: () => import(/* webpackChunkName: "backtest" */ '@/views/Backtesting.vue'), + component: () => import( '@/views/Backtesting.vue'), }, { path: '/dashboard', name: 'Freqtrade Dashboard', - component: () => import(/* webpackChunkName: "dashboard" */ '@/views/Dashboard.vue'), + component: () => import('@/views/Dashboard.vue'), }, { path: '/balance', @@ -65,12 +65,12 @@ const routes: Array = [ { path: '/settings', name: 'Freqtrade Settings', - component: () => import(/* webpackChunkName: "dashboard" */ '@/views/Settings.vue'), + component: () => import( '@/views/Settings.vue'), }, { path: '/login', name: 'Login', - component: () => import(/* webpackChunkName: "login" */ '@/views/LoginView.vue'), + component: () => import('@/views/LoginView.vue'), meta: { allowAnonymous: true, }, @@ -84,7 +84,7 @@ const routes: Array = [ const router = new VueRouter({ mode: 'history', - base: process.env.BASE_URL, + base: import.meta.env.BASE_URL, routes, }); diff --git a/src/store/index.ts b/src/store/index.ts index 089fd643..73678fcb 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -60,7 +60,7 @@ const store = new Vuex.Store({ commit('setLoggedIn', loggedin); }, async loadUIVersion({ commit }) { - if (process.env.NODE_ENV !== 'development') { + if (import.meta.env.PROD) { try { const result = await axios.get('/ui_version'); const { version } = result.data; diff --git a/src/styles/main.scss b/src/styles/main.scss index c0f48872..37f6c6c4 100644 --- a/src/styles/main.scss +++ b/src/styles/main.scss @@ -1,8 +1,8 @@ @import 'bootstrap_variables_ovw'; -@import '~bootstrap/scss/bootstrap'; -@import '~bootstrap-vue/src/index'; +@import 'bootstrap/scss/bootstrap'; +@import 'bootstrap-vue/src/index'; @import "vue-select/src/scss/vue-select.scss"; @import 'variables'; diff --git a/src/views/Error404.vue b/src/views/Error404.vue index d9a53289..11a9a3a1 100644 --- a/src/views/Error404.vue +++ b/src/views/Error404.vue @@ -2,7 +2,8 @@

404 Error.

Ahhhhhhhh! The page you are looking for does not exist.

-

Don't worry, you can head back to the main page.

+

Don't worry, you can head back to + the main page.

diff --git a/src/views/Home.vue b/src/views/Home.vue index 54dc09b5..76950a8d 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -31,12 +31,13 @@ import BotList from '@/components/BotList.vue'; export default class Home extends Vue {} -