mirror of
https://gitee.com/dromara/go-view.git
synced 2025-10-15 06:52:10 +08:00
build:
1、添加图片压缩插件 2、添加打包分析插件 3、删除为用到的依赖 4、配置文件返回修改为函数形式
This commit is contained in:
parent
06114f8b95
commit
7dcb06fec8
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,3 +5,4 @@ dist
|
||||
dist-ssr
|
||||
*.local
|
||||
.vscode
|
||||
./stats.html
|
12
package.json
12
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"
|
||||
|
@ -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'
|
||||
|
||||
|
6
src/packages/index.d.ts
vendored
6
src/packages/index.d.ts
vendored
@ -119,9 +119,9 @@ export interface CreateComponentType extends PublicConfigType {
|
||||
key: string
|
||||
chartConfig: ConfigType
|
||||
option: GlobalThemeJsonType
|
||||
eventList: Array<OptionsType>
|
||||
methodList: Array<OptionsType>
|
||||
eventConfig: EventConfig
|
||||
eventList?: Array<OptionsType>
|
||||
methodList?: Array<OptionsType>
|
||||
eventConfig?: EventConfig
|
||||
}
|
||||
|
||||
// 获取组件实例类中某个key对应value类型的方法
|
||||
|
160
vite.config.ts
160
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
|
||||
}
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user