From c7c63c51de6a019927a172cdf99db62da1136307 Mon Sep 17 00:00:00 2001
From: LiuHao <liuhaoai545@gmail.com>
Date: 星期日, 02 四月 2023 15:07:14 +0800
Subject: [PATCH] fix style and add plugin
---
src/assets/styles/index.scss | 2 +-
Vite/plugins/compression.ts | 28 ++++++++++++++++++++++++++++
Vite/plugins/index.ts | 4 +++-
Vite/plugins/svg-icon.ts | 5 +++--
src/types/auto-imports.d.ts | 2 ++
5 files changed, 37 insertions(+), 4 deletions(-)
diff --git a/Vite/plugins/compression.ts b/Vite/plugins/compression.ts
new file mode 100644
index 0000000..b710eb5
--- /dev/null
+++ b/Vite/plugins/compression.ts
@@ -0,0 +1,28 @@
+import compression from 'vite-plugin-compression';
+
+export default function createCompression(env) {
+ const { VITE_BUILD_COMPRESS } = env;
+ const plugin: any[] = [];
+ if (VITE_BUILD_COMPRESS) {
+ const compressList = VITE_BUILD_COMPRESS.split(',');
+ if (compressList.includes('gzip')) {
+ // http://doc.ruoyi.vip/ruoyi-vue/other/faq.html#浣跨敤gzip瑙e帇缂╅潤鎬佹枃浠�
+ plugin.push(
+ compression({
+ ext: '.gz',
+ deleteOriginFile: false
+ })
+ );
+ }
+ if (compressList.includes('brotli')) {
+ plugin.push(
+ compression({
+ ext: '.br',
+ algorithm: 'brotliCompress',
+ deleteOriginFile: false
+ })
+ );
+ }
+ }
+ return plugin;
+}
diff --git a/Vite/plugins/index.ts b/Vite/plugins/index.ts
index 001b56c..eebea14 100644
--- a/Vite/plugins/index.ts
+++ b/Vite/plugins/index.ts
@@ -4,6 +4,7 @@
import createComponents from './components';
import createIcons from './icons';
import createSvgIconsPlugin from './svg-icon';
+import createCompression from './compression';
import path from 'path';
export default (viteEnv, isBuild = false): [] => {
@@ -12,7 +13,8 @@
vitePlusgins.push(createUnoCss());
vitePlusgins.push(createAutoImport(path));
vitePlusgins.push(createComponents(path));
+ vitePlusgins.push(createCompression(viteEnv));
vitePlusgins.push(createIcons());
- vitePlusgins.push(createSvgIconsPlugin(path));
+ vitePlusgins.push(createSvgIconsPlugin(path, isBuild));
return vitePlusgins;
};
diff --git a/Vite/plugins/svg-icon.ts b/Vite/plugins/svg-icon.ts
index 0d83ce0..0ee8d65 100644
--- a/Vite/plugins/svg-icon.ts
+++ b/Vite/plugins/svg-icon.ts
@@ -1,9 +1,10 @@
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
-export default (path: any) => {
+export default (path: any, isBuild: boolean) => {
return createSvgIconsPlugin({
// 鎸囧畾闇�瑕佺紦瀛樼殑鍥炬爣鏂囦欢澶�
iconDirs: [path.resolve(path.resolve(__dirname, '../../src'), 'assets/icons/svg')],
// 鎸囧畾symbolId鏍煎紡
- symbolId: 'icon-[dir]-[name]'
+ symbolId: 'icon-[dir]-[name]',
+ svgoOptions: isBuild
});
};
diff --git a/src/assets/styles/index.scss b/src/assets/styles/index.scss
index dd052f6..c768719 100644
--- a/src/assets/styles/index.scss
+++ b/src/assets/styles/index.scss
@@ -6,7 +6,7 @@
@import './btn.scss';
@import './ruoyi.scss';
@import 'animate.css';
-// @import 'element-plus/dist/index.css';
+@import 'element-plus/dist/index.css';
body {
height: 100%;
diff --git a/src/types/auto-imports.d.ts b/src/types/auto-imports.d.ts
index 9e54a50..ae42063 100644
--- a/src/types/auto-imports.d.ts
+++ b/src/types/auto-imports.d.ts
@@ -8,6 +8,7 @@
const ElMessageBox: typeof import('element-plus/es')['ElMessageBox']
const ElNotification: typeof import('element-plus/es')['ElNotification']
const ElSelect: typeof import('element-plus/es')['ElSelect']
+ const ElTable: typeof import('element-plus/es')['ElTable']
const acceptHMRUpdate: typeof import('pinia')['acceptHMRUpdate']
const asyncComputed: typeof import('@vueuse/core')['asyncComputed']
const autoResetRef: typeof import('@vueuse/core')['autoResetRef']
@@ -293,6 +294,7 @@
readonly ElMessageBox: UnwrapRef<typeof import('element-plus/es')['ElMessageBox']>
readonly ElNotification: UnwrapRef<typeof import('element-plus/es')['ElNotification']>
readonly ElSelect: UnwrapRef<typeof import('element-plus/es')['ElSelect']>
+ readonly ElTable: UnwrapRef<typeof import('element-plus/es')['ElTable']>
readonly acceptHMRUpdate: UnwrapRef<typeof import('pinia')['acceptHMRUpdate']>
readonly asyncComputed: UnwrapRef<typeof import('@vueuse/core')['asyncComputed']>
readonly autoResetRef: UnwrapRef<typeof import('@vueuse/core')['autoResetRef']>
--
Gitblit v1.9.3