chore: 浏览器兼容性配置

This commit is contained in:
baiqi 2024-07-05 16:00:02 +08:00 committed by Craftsman
parent 5bfd7d62bd
commit 8ecc9185ac
6 changed files with 23 additions and 59 deletions

View File

@ -73,10 +73,11 @@ Closes #123
│ │ ├── modules // 各业务模块的请求方法
│ │ ├── requrls // 按业务模块划分的接口地址
│ ├── assets // 全局静态资源
│ │ ├── font
│ │ ├── icon-font
│ │ ├── images
- svg
│ │ ├── logo.svg
│ │ ├── style
│ │ ├── svg
│ ├── components // 组件
│ ├── config // 全局配置常量类、JSON
│ ├── directive // 自定义指令集
@ -85,7 +86,6 @@ Closes #123
│ ├── layout // 应用布局组件
│ ├── locale // 国际化配置
│ ├── main.ts // 项目主入口
│ ├── mock // mock数据配置
│ ├── models // 全局数据模型定义
│ ├── router // 路由
│ ├── store // pinia状态库
@ -580,7 +580,6 @@ module.exports = {
"lib": ["esnext", "dom"],
"skipLibCheck": true, // 跳过node依赖包语法检查
"types": [
// "vitest/globals",
// "vite-plugin-svg-icons/client"
], // 手动导入TS类型声明文件
"baseUrl": ".",
@ -706,39 +705,6 @@ export default mergeConfig(
);
```
## 单元测试
测试框架vitest
单元测试实用工具库: @vue/test-utils
测试环境: js-dom
报告: @vitest/coverage-c8
```bash
pnpm add -D vitest @vue/test-utils js-dom @vitest/coverage-c8
```
配置
根目录新建 vitest.config.ts
```typescript
import { mergeConfig } from 'vite';
import { defineConfig } from 'vitest/config';
import viteConfig from './config/vite.config.dev';
export default mergeConfig(
viteConfig,
defineConfig({
test: {
environment: 'jsdom',
},
})
);
```
## 本地生产环境调试
需安装 docker https://www.docker.com/, 选择对应系统版本安装。

View File

@ -1,4 +1,3 @@
/// <reference types="vitest" />
import baseConfig from './vite.config.base';
import dotenv from 'dotenv';
import { mergeConfig } from 'vite';

View File

@ -1,12 +1,20 @@
import configCompressPlugin from './plugin/compress';
import configVisualizerPlugin from './plugin/visualizer';
import baseConfig from './vite.config.base';
import legacy from '@vitejs/plugin-legacy';
import { mergeConfig } from 'vite';
export default mergeConfig(
{
mode: 'production',
plugins: [configCompressPlugin('gzip'), configVisualizerPlugin()],
plugins: [
configCompressPlugin('gzip'),
configVisualizerPlugin(),
// 兼容性配置配合package.json中的browserslist使用
legacy({
targets: ['defaults', 'not IE 11'],
}),
],
build: {
rollupOptions: {
output: {
@ -14,6 +22,7 @@ export default mergeConfig(
vue: ['vue', 'vue-router', 'pinia', '@vueuse/core', 'vue-i18n'],
arco: ['@arco-design/web-vue'],
chart: ['echarts', 'vue-echarts'],
codeEditor: ['monaco-editor'],
},
},
},

View File

@ -1,7 +1,7 @@
{
"name": "meter-sphere",
"description": "MeterSphere FrontEnd",
"version": "3.0.0",
"version": "3.1.0",
"private": true,
"author": "MeterSphere Team",
"license": "MIT",
@ -16,9 +16,7 @@
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix",
"lint:styles": "stylelint 'src/**/*.{vue,html,css,scss,less}' --fix",
"lint-staged": "npx lint-staged",
"prepare": "cd .. && husky install frontend/.husky",
"test": "vitest",
"coverage": "vitest run --coverage"
"prepare": "cd .. && husky install frontend/.husky"
},
"lint-staged": {
"*.{js,ts,jsx,tsx}": [
@ -102,9 +100,9 @@
"@types/sortablejs": "^1.15.8",
"@typescript-eslint/eslint-plugin": "^7.15.0",
"@typescript-eslint/parser": "^7.15.0",
"@vitejs/plugin-legacy": "^4.1.1",
"@vitejs/plugin-vue": "^4.6.2",
"@vitejs/plugin-vue-jsx": "^3.1.0",
"@vitest/coverage-c8": "^0.31.4",
"@vue/babel-plugin-jsx": "^1.2.2",
"@vue/test-utils": "^2.4.6",
"autoprefixer": "^10.4.19",
@ -159,15 +157,20 @@
"vite-plugin-svg-icons": "^2.0.1",
"vite-plugin-vue-setup-extend": "^0.4.0",
"vite-svg-loader": "^3.6.0",
"vitest": "^0.31.4",
"vue-tsc": "^1.8.27"
},
"engines": {
"node": ">=18.0.0"
},
"browserslist": [
"> 0.5%",
"last 2 versions",
"not dead",
"not IE 11"
],
"resolutions": {
"bin-wrapper": "npm:bin-wrapper-china",
"rollup": "^4.18.0",
"gifsicle": "5.2.0"
}
}
}

View File

@ -35,7 +35,6 @@
"skipLibCheck": true, // node
"types": [
"node",
// "vitest/globals",
// "vite-plugin-svg-icons/client"
], // TS
"baseUrl": ".",

View File

@ -1,12 +0,0 @@
import viteConfig from './config/vite.config.dev';
import { mergeConfig } from 'vite';
import { defineConfig } from 'vitest/config';
export default mergeConfig(
viteConfig,
defineConfig({
test: {
environment: 'jsdom',
},
})
);