diff --git a/.gitignore b/.gitignore index e8de8f67..00e4e9e3 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ dist dist-ssr *.local .vscode +./stats.html \ No newline at end of file diff --git a/package.json b/package.json index 290d0829..149915b9 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "1.0.6", "scripts": { "dev": "vite --host", - "build": "vue-tsc --noEmit && vite build", + "build": "vite build", "preview": "vite preview", "new": "plop --plopfile ./plop/plopfile.js", "postinstall": "husky install" @@ -28,7 +28,6 @@ "screenfull": "^6.0.1", "tiny-emitter": "^2.1.0", "vue": "^3.2.31", - "vue-demi": "^0.13.1", "vue-echarts": "^6.0.2", "vue-i18n": "9.1.9", "vue-router": "4.0.12", @@ -37,19 +36,17 @@ "vuedraggable": "^4.1.0" }, "devDependencies": { + "@commitlint/cli": "^17.0.2", + "@commitlint/config-conventional": "^17.0.2", "@types/color": "^3.0.3", "@types/crypto-js": "^4.1.1", "@types/keymaster": "^1.6.30", - "@commitlint/cli": "^17.0.2", - "@commitlint/config-conventional": "^17.0.2", - "@types/node": "^16.11.26", "@typescript-eslint/eslint-plugin": "^5.18.0", "@typescript-eslint/parser": "^5.18.0", "@vitejs/plugin-vue": "^1.10.2", "@vitejs/plugin-vue-jsx": "^1.3.9", "@vue/compiler-sfc": "^3.2.31", "commitlint": "^17.0.2", - "default-passive-events": "^2.0.0", "eslint": "^8.12.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-import": "^2.26.0", @@ -59,12 +56,13 @@ "mockjs": "^1.1.0", "plop": "^3.0.5", "prettier": "^2.6.2", + "rollup-plugin-visualizer": "^5.7.1", "sass": "^1.49.11", "sass-loader": "^12.6.0", "typescript": "^4.6.3", "vite": "2.9.5", "vite-plugin-compression": "^0.5.1", - "vite-plugin-importer": "^0.2.5", + "vite-plugin-imagemin": "^0.6.1", "vite-plugin-mock": "^2.9.6", "vite-plugin-monaco-editor": "^1.1.0", "vue-tsc": "^0.28.10" diff --git a/src/packages/components/Decorates/Decorates/Decorates04/config.ts b/src/packages/components/Decorates/Decorates/Decorates04/config.ts index 8eaf77d2..61b51a97 100644 --- a/src/packages/components/Decorates/Decorates/Decorates04/config.ts +++ b/src/packages/components/Decorates/Decorates/Decorates04/config.ts @@ -1,5 +1,5 @@ import { publicConfig } from '@/packages/public' -import { CreateComponentType } from '@/packages/index.d' +import { CreateComponentType, EventConfig, OptionsType } from '@/packages/index.d' import { Decorates04Config } from './index' import cloneDeep from 'lodash/cloneDeep' diff --git a/src/packages/index.d.ts b/src/packages/index.d.ts index 6a3b4eb1..b2805beb 100644 --- a/src/packages/index.d.ts +++ b/src/packages/index.d.ts @@ -119,9 +119,9 @@ export interface CreateComponentType extends PublicConfigType { key: string chartConfig: ConfigType option: GlobalThemeJsonType - eventList: Array - methodList: Array - eventConfig: EventConfig + eventList?: Array + methodList?: Array + eventConfig?: EventConfig } // 获取组件实例类中某个key对应value类型的方法 diff --git a/vite.config.ts b/vite.config.ts index 8c941c37..94e076cc 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -5,67 +5,117 @@ import { OUTPUT_DIR, brotliSize, chunkSizeWarningLimit, terserOptions, rollupOpt import viteCompression from 'vite-plugin-compression' import { viteMockServe } from 'vite-plugin-mock' import monacoEditorPlugin from 'vite-plugin-monaco-editor' +import { visualizer } from "rollup-plugin-visualizer"; +import viteImagemin from 'vite-plugin-imagemin' function pathResolve(dir: string) { return resolve(process.cwd(), '.', dir) } -export default defineConfig({ - base: '/', - // 路径重定向 - resolve: { - alias: [ - { - find: /\/#\//, - replacement: pathResolve('types') + '/' - }, - { - find: '@', - replacement: pathResolve('src') + '/' - } - ], - dedupe: ['vue'] - }, - // 全局 css 注册 - css: { - preprocessorOptions: { - scss: { - javascriptEnabled: true, - additionalData: `@import "src/styles/common/style.scss";` +const plugins = [ + vue(), + monacoEditorPlugin({ + languageWorkers: ['editorWorkerService', 'typescript', 'json', 'html'] + }), +] + +const devPlugins = [ + viteMockServe({ + mockPath: '/src/api/mock', + // 开发打包开关 + localEnabled: true, + // 生产打包开关 + prodEnabled: true, + // 打开后,可以读取 ts 文件模块。 请注意,打开后将无法监视.js 文件 + supportTs: true, + // 监视文件更改 + watchFiles: true + }), +] +const proPlugins = [ + // 图片压缩 + viteImagemin({ + gifsicle: { + optimizationLevel: 7, + interlaced: false, + }, + optipng: { + optimizationLevel: 7, + }, + mozjpeg: { + quality: 20, + }, + pngquant: { + quality: [0.8, 0.9], + speed: 4, + }, + svgo: { + plugins: [ + { + name: 'removeViewBox', + }, + { + name: 'removeEmptyAttrs', + active: false, + }, + ], + }, + }), + // 压缩 + viteCompression({ + verbose: true, + disable: false, + threshold: 10240, + algorithm: 'gzip', + ext: '.gz' + }), + // 打包分析 + visualizer({ + open: true + }) +] + +export default defineConfig(({ mode }) => { + if(mode === 'development'){ + plugins.push(...devPlugins) + }else{ + plugins.push(...proPlugins) + + } + + return { + base: '/', + // 路径重定向 + resolve: { + alias: [ + { + find: /\/#\//, + replacement: pathResolve('types') + '/' + }, + { + find: '@', + replacement: pathResolve('src') + '/' + } + ], + dedupe: ['vue'] + }, + // 全局 css 注册 + css: { + preprocessorOptions: { + scss: { + javascriptEnabled: true, + additionalData: `@import "src/styles/common/style.scss";` + } } + }, + plugins, + build: { + target: 'es2015', + outDir: OUTPUT_DIR, + terserOptions: terserOptions, + rollupOptions: rollupOptions, + brotliSize: brotliSize, + chunkSizeWarningLimit: chunkSizeWarningLimit } - }, - plugins: [ - vue(), - monacoEditorPlugin({ - languageWorkers: ['editorWorkerService', 'typescript', 'json', 'html'] - }), - viteMockServe({ - mockPath: '/src/api/mock', - // 开发打包开关 - localEnabled: true, - // 生产打包开关 - prodEnabled: true, - // 打开后,可以读取 ts 文件模块。 请注意,打开后将无法监视.js 文件 - supportTs: true, - // 监视文件更改 - watchFiles: true - }), - // 压缩 - viteCompression({ - verbose: true, - disable: false, - threshold: 10240, - algorithm: 'gzip', - ext: '.gz' - }) - ], - build: { - target: 'es2015', - outDir: OUTPUT_DIR, - terserOptions: terserOptions, - rollupOptions: rollupOptions, - brotliSize: brotliSize, - chunkSizeWarningLimit: chunkSizeWarningLimit } })